Streamingcommunity WIP

This commit is contained in:
UrloMythus
2024-07-08 18:11:07 +02:00 Unverified
parent bb97ff4e8a
commit 497b4dfc09
11 changed files with 99 additions and 19 deletions
+1 -1
View File
@@ -1 +1 @@
.env .env
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -3
View File
@@ -21,6 +21,4 @@ def get_TMDb_id_from_IMDb_id(imdb_id):
print(tmbda['tv_results'][0]['id']) print(tmbda['tv_results'][0]['id'])
return tmbda['tv_results'][0]['id'], season, episode , ismovie return tmbda['tv_results'][0]['id'], season, episode , ismovie
else: else:
return None return None
get_TMDb_id_from_IMDb_id("tt1839578:1:1")
+19
View File
@@ -17,4 +17,23 @@ def convert_US_date(date):
latest_release_date = us_release_dates_type_4[0]['release_date'] latest_release_date = us_release_dates_type_4[0]['release_date']
date = latest_release_date.split('T')[0] date = latest_release_date.split('T')[0]
print('Latest US theatrical release date (type 4):', date) 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 return date
+7 -6
View File
@@ -9,7 +9,7 @@ import dateparser
from convert import get_TMDb_id_from_IMDb_id from convert import get_TMDb_id_from_IMDb_id
from loadenv import load_env from loadenv import load_env
from info import get_info from info import get_info
from US_date import convert_US_date from convert_date import convert_US_date
TMDB_KEY, DOMAIN = load_env() TMDB_KEY, DOMAIN = load_env()
headers = { headers = {
@@ -86,12 +86,13 @@ def get_true_link(real_link):
return s return s
def get_stream_link(imbd): def get_stream_link(imbd):
info = get_TMDb_id_from_IMDb_id(imbd) general = get_TMDb_id_from_IMDb_id(imbd)
if len(info)==4 : if len(general)==4 :
tmdba,season,episode,ismovie = info tmdba,season,episode,ismovie = general
else: else:
tmdba,ismovie = info tmdba,ismovie = general
showname,date = get_info(tmdba,ismovie) type = "Filmpertutti"
showname,date = get_info(tmdba,ismovie,type)
showname = showname.replace(" ", "+").replace("–", "+").replace("—","+") showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
query = f'https://filmpertutti.{DOMAIN}/wp-json/wp/v2/posts?search={showname}&page=1&_fields=link,id' query = f'https://filmpertutti.{DOMAIN}/wp-json/wp/v2/posts?search={showname}&page=1&_fields=link,id'
print(query) print(query)
+14 -6
View File
@@ -1,9 +1,9 @@
from loadenv import load_env from loadenv import load_env
from tmdbv3api import TMDb, Movie, TV from tmdbv3api import TMDb, Movie, TV
from US_date import convert_US_date from convert_date import convert_US_date, convert_IT_date
TMDB_KEY, DOMAIN = load_env() TMDB_KEY, DOMAIN, FILMPERTUTTI,STREAMINGCOMMUNITY = load_env()
def get_info(tmbda,ismovie): def get_info(tmbda,ismovie,type):
tmdb = TMDb() tmdb = TMDb()
tmdb.api_key = f'{TMDB_KEY}' tmdb.api_key = f'{TMDB_KEY}'
tmdb.language = 'it' tmdb.language = 'it'
@@ -11,15 +11,23 @@ def get_info(tmbda,ismovie):
tv = TV() tv = TV()
show= tv.details(tmbda) show= tv.details(tmbda)
showname = show.name showname = show.name
date= show.first_air_date if type == "Filmpertutti":
date= show.first_air_date
elif type == "StreamingCommunity":
date = show.last_air_date
print("Real date",date)
else: else:
movie = Movie() movie = Movie()
show= movie.details(tmbda) show= movie.details(tmbda)
showname= show.title showname= show.title
#Get all release dates #Get all release dates
date = show.release_dates date = show.release_dates
#GET US RELEASE DATE because filmpertutti somewhy uses US release date if type == "Filmpertutti":
date = convert_US_date(date) #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: if ismovie==0:
return showname,date return showname,date
else: else:
+3 -1
View File
@@ -4,4 +4,6 @@ load_dotenv(".env")
def load_env(): def load_env():
TMDB_KEY = os.getenv('TMDB_KEY') TMDB_KEY = os.getenv('TMDB_KEY')
DOMAIN = os.getenv('DOMAIN') DOMAIN = os.getenv('DOMAIN')
return TMDB_KEY, DOMAIN FILMPERTUTTI = os.getenv('FILMPERTUTTI')
STREAMINGCOMMUNITY = os.getenv('STREAMINGCOMMUNITY')
return TMDB_KEY, DOMAIN, FILMPERTUTTI, STREAMINGCOMMUNITY
+6 -2
View File
@@ -1,5 +1,7 @@
from flask import Flask, jsonify, abort from flask import Flask, jsonify, abort
from filmpertutti import get_stream_link from filmpertutti import get_stream_link
from loadenv import load_env
TMDB_KEY, DOMAIN, FILMPERTUTTI, STREAMINGCOMMUNITY = load_env()
app = Flask(__name__) app = Flask(__name__)
@@ -34,8 +36,10 @@ def root():
def addon_stream(type, id): def addon_stream(type, id):
if type not in MANIFEST['types']: if type not in MANIFEST['types']:
abort(404) abort(404)
if FILMPERTUTTI == 1:
url = get_stream_link(id) # call the function to dynamically get stream links 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}]} streams = {'streams': [{'title': 'Stream URL', 'url': url}]}
+48
View File
@@ -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")