Streamingcommunity WIP
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -22,5 +22,3 @@ def get_TMDb_id_from_IMDb_id(imdb_id):
|
||||
return tmbda['tv_results'][0]['id'], season, episode , ismovie
|
||||
else:
|
||||
return None
|
||||
|
||||
get_TMDb_id_from_IMDb_id("tt1839578:1:1")
|
||||
@@ -18,3 +18,22 @@ def convert_US_date(date):
|
||||
date = latest_release_date.split('T')[0]
|
||||
print('Latest US theatrical release date (type 4):', date)
|
||||
return date
|
||||
def convert_IT_date(date):
|
||||
it_data = next((country_data for country_data in date['results'] if country_data["iso_3166_1"] == "IT"), None)
|
||||
if it_data:
|
||||
it_release_dates_type_3 = [rd for rd in it_data['release_dates'] if rd['type'] == 3]
|
||||
# Sort the list of release dates and get the latest
|
||||
it_release_dates_type_3.sort(key = lambda x: x['release_date'], reverse=True)
|
||||
if len(it_release_dates_type_3) > 0:
|
||||
latest_release_date = it_release_dates_type_3[0]['release_date']
|
||||
date = latest_release_date.split('T')[0]
|
||||
print('Latest IT theatrical release date:', date)
|
||||
return date
|
||||
else:
|
||||
it_release_dates_type_4 = [rd for rd in it_data['release_dates'] if rd['type'] == 4]
|
||||
it_release_dates_type_4.sort(key = lambda x: x['release_date'], reverse=True)
|
||||
if len(it_release_dates_type_4) > 0:
|
||||
latest_release_date = it_release_dates_type_4[0]['release_date']
|
||||
date = latest_release_date.split('T')[0]
|
||||
print('Latest IT theatrical release date (type 4):', date)
|
||||
return date
|
||||
+7
-6
@@ -9,7 +9,7 @@ import dateparser
|
||||
from convert import get_TMDb_id_from_IMDb_id
|
||||
from loadenv import load_env
|
||||
from info import get_info
|
||||
from US_date import convert_US_date
|
||||
from convert_date import convert_US_date
|
||||
|
||||
TMDB_KEY, DOMAIN = load_env()
|
||||
headers = {
|
||||
@@ -86,12 +86,13 @@ def get_true_link(real_link):
|
||||
return s
|
||||
|
||||
def get_stream_link(imbd):
|
||||
info = get_TMDb_id_from_IMDb_id(imbd)
|
||||
if len(info)==4 :
|
||||
tmdba,season,episode,ismovie = info
|
||||
general = get_TMDb_id_from_IMDb_id(imbd)
|
||||
if len(general)==4 :
|
||||
tmdba,season,episode,ismovie = general
|
||||
else:
|
||||
tmdba,ismovie = info
|
||||
showname,date = get_info(tmdba,ismovie)
|
||||
tmdba,ismovie = general
|
||||
type = "Filmpertutti"
|
||||
showname,date = get_info(tmdba,ismovie,type)
|
||||
showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
|
||||
query = f'https://filmpertutti.{DOMAIN}/wp-json/wp/v2/posts?search={showname}&page=1&_fields=link,id'
|
||||
print(query)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from loadenv import load_env
|
||||
from tmdbv3api import TMDb, Movie, TV
|
||||
from US_date import convert_US_date
|
||||
TMDB_KEY, DOMAIN = load_env()
|
||||
from convert_date import convert_US_date, convert_IT_date
|
||||
TMDB_KEY, DOMAIN, FILMPERTUTTI,STREAMINGCOMMUNITY = load_env()
|
||||
|
||||
def get_info(tmbda,ismovie):
|
||||
def get_info(tmbda,ismovie,type):
|
||||
tmdb = TMDb()
|
||||
tmdb.api_key = f'{TMDB_KEY}'
|
||||
tmdb.language = 'it'
|
||||
@@ -11,15 +11,23 @@ def get_info(tmbda,ismovie):
|
||||
tv = TV()
|
||||
show= tv.details(tmbda)
|
||||
showname = show.name
|
||||
if type == "Filmpertutti":
|
||||
date= show.first_air_date
|
||||
elif type == "StreamingCommunity":
|
||||
date = show.last_air_date
|
||||
print("Real date",date)
|
||||
else:
|
||||
movie = Movie()
|
||||
show= movie.details(tmbda)
|
||||
showname= show.title
|
||||
#Get all release dates
|
||||
date = show.release_dates
|
||||
if type == "Filmpertutti":
|
||||
#GET US RELEASE DATE because filmpertutti somewhy uses US release date
|
||||
date = convert_US_date(date)
|
||||
elif type == "StreamingCommunity":
|
||||
date = convert_IT_date(date)
|
||||
print (date)
|
||||
if ismovie==0:
|
||||
return showname,date
|
||||
else:
|
||||
|
||||
+3
-1
@@ -4,4 +4,6 @@ load_dotenv(".env")
|
||||
def load_env():
|
||||
TMDB_KEY = os.getenv('TMDB_KEY')
|
||||
DOMAIN = os.getenv('DOMAIN')
|
||||
return TMDB_KEY, DOMAIN
|
||||
FILMPERTUTTI = os.getenv('FILMPERTUTTI')
|
||||
STREAMINGCOMMUNITY = os.getenv('STREAMINGCOMMUNITY')
|
||||
return TMDB_KEY, DOMAIN, FILMPERTUTTI, STREAMINGCOMMUNITY
|
||||
@@ -1,5 +1,7 @@
|
||||
from flask import Flask, jsonify, abort
|
||||
from filmpertutti import get_stream_link
|
||||
from loadenv import load_env
|
||||
TMDB_KEY, DOMAIN, FILMPERTUTTI, STREAMINGCOMMUNITY = load_env()
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@@ -34,8 +36,10 @@ def root():
|
||||
def addon_stream(type, id):
|
||||
if type not in MANIFEST['types']:
|
||||
abort(404)
|
||||
|
||||
if FILMPERTUTTI == 1:
|
||||
url = get_stream_link(id) # call the function to dynamically get stream links
|
||||
elif STREAMINGCOMMUNITY == 1:
|
||||
return "Not implemented yet"
|
||||
|
||||
|
||||
streams = {'streams': [{'title': 'Stream URL', 'url': url}]}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
from tmdbv3api import TMDb, Movie, TV
|
||||
import requests
|
||||
from bs4 import BeautifulSoup,SoupStrainer
|
||||
from datetime import datetime
|
||||
import dateparser
|
||||
from convert import get_TMDb_id_from_IMDb_id
|
||||
from loadenv import load_env
|
||||
from info import get_info
|
||||
TMDB_KEY= load_env()
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.10; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
|
||||
'Accept-Language': 'en-US,en;q=0.5'
|
||||
}
|
||||
def streaming_community(imbd):
|
||||
print(load_env)
|
||||
general = get_TMDb_id_from_IMDb_id(imbd)
|
||||
if len(general)==4 :
|
||||
tmdba,season,episode,ismovie = general
|
||||
else:
|
||||
tmdba,ismovie = general
|
||||
type = "StreamingCommunity"
|
||||
showname,date = get_info(tmdba,ismovie,type)
|
||||
showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
|
||||
query = f'https://streamingcommunity.boston/api/search?q={showname}'
|
||||
date,tid,slug = search(query,date)
|
||||
if ismovie == 0:
|
||||
url = get_film(tid)
|
||||
return "NOT IMPLEMENTED YET"
|
||||
|
||||
|
||||
|
||||
def search(query,date):
|
||||
response = requests.get(query).json()
|
||||
for json in response:
|
||||
release_date = json['last_air_date']
|
||||
tid = json['id']
|
||||
slug = json['slug']
|
||||
if date == release_date:
|
||||
return date,tid,slug
|
||||
def get_film(tid):
|
||||
url = f'https://streamingcommunity.boston/watch/{tid}'
|
||||
response = requests.get(url, headers=headers)
|
||||
soup = BeautifulSoup(response.text, 'lxml', parse_only=SoupStrainer('iframe'))
|
||||
vixid = soup['src']
|
||||
vixid = vixid.split("/embed/")[1].split("?")[0]
|
||||
print (vixid)
|
||||
|
||||
streaming_community("tt16426418")
|
||||
Reference in New Issue
Block a user