From 79442b658b9f5db9f2cd46a28cf85f1416364312 Mon Sep 17 00:00:00 2001 From: UrloMythus Date: Sun, 14 Jul 2024 12:01:31 +0200 Subject: [PATCH] added tuttifilm --- README.md | 2 +- config.json | 5 +- config.py | 2 + convert.py | 4 +- cool.py | 144 +++++++++++++++++++++++++++++++++++++++--- info.py | 11 +++- loadenv.py | 6 +- run.py | 16 ++++- streamingcommunity.py | 97 ++++++++++++++-------------- tantifilm.py | 88 +++++++++++++------------- 10 files changed, 267 insertions(+), 108 deletions(-) diff --git a/README.md b/README.md index f8e31fa..8def76b 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ In the repo there is a config.json that you can modify to change some aspects of |HOST| The host for the Flask APP| |PORT| The port for the Flask APP. Default: 8080 | - + For now Mysterius must be kept disabled if you do not know what you are doing. Check those links to get the new Domain for the providers. diff --git a/config.json b/config.json index 9b77ff0..e11844c 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "Siti": { "StreamingCommunity": { - "enabled": "0", + "enabled": "1", "domain": "boston", "fast_search": "1" }, @@ -13,6 +13,9 @@ "enabled": "1", "domain": "bond", "fast_search": "0" + }, + "Mysterius":{ + "enabled": "0" } }, "General":{ diff --git a/config.py b/config.py index 833bbda..fd68d84 100644 --- a/config.py +++ b/config.py @@ -13,6 +13,8 @@ SC_DOMAIN = SITE["StreamingCommunity"]['domain'] TF_DOMAIN = SITE["Tuttifilm"]['enabled'] FILMPERTUTTI = SITE["Filmpertutti"]['enabled'] STREAMINGCOMMUNITY = SITE["StreamingCommunity"]['enabled'] +MYSTERIUS = SITE["Mysterius"]['enabled'] +TUTTIFILM = SITE["Tuttifilm"]['enabled'] SC_FAST_SEARCH = SITE["StreamingCommunity"]['fast_search'] TF_FAST_SEARCH = SITE["Tuttifilm"]['fast_search'] #General diff --git a/convert.py b/convert.py index d5531c7..5266574 100644 --- a/convert.py +++ b/convert.py @@ -1,7 +1,7 @@ -import requests +import requests from tmdbv3api import TMDb, Movie, TV from loadenv import load_env -TMDB_KEY= load_env() +TMDB_KEY,_= load_env() def get_TMDb_id_from_IMDb_id(imdb_id): response = requests.get(f'https://api.themoviedb.org/3/find/{imdb_id}', params={'external_source': 'imdb_id', 'api_key': f'{TMDB_KEY}'}) diff --git a/cool.py b/cool.py index 0a36573..2d8777f 100644 --- a/cool.py +++ b/cool.py @@ -1,11 +1,139 @@ -from tmdbv3api import TMDb, Movie, TV import requests -import logging -from bs4 import BeautifulSoup,SoupStrainer -from datetime import datetime -import dateparser -from convert import get_TMDb_id_from_IMDb_id -from info import get_info_tmdb, is_movie, get_info_imdb -import config import json +from info import get_info_tmdb,is_movie +from convert import get_TMDb_id_from_IMDb_id +from loadenv import load_env +_,MYSTERIUS_KEY = load_env() +def get_links(slug,season,episode,ismovie): + try: + headers = { + "x-api-key": MYSTERIUS_KEY + } + response = requests.get("https://mythus-ulala1243.hf.space/api/cookie", headers=headers) + print(response.text) + Auths = response.json() + Bearer = Auths.get('cookie') + ap_session = Auths.get('auth') + cookies = {'ap_session': ap_session} + + headers = { + 'accept': 'application/json, text/plain, */*', + 'accept-language': 'it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7', + 'authorization': f'Bearer {Bearer}', + 'referer': f'https://altadefinizione-originale.com/play/{slug}', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 OPR/111.0.0.0', + 'x-requested-with': 'XMLHttpRequest', + } + if ismovie == 1: + + response = requests.get(f'https://altadefinizione-originale.com/api/post/urls/stream/{slug}',cookies=cookies,headers=headers) + elif ismovie == 0: + response = requests.get(f'https://altadefinizione-originale.com/api/post/urls/stream/{slug}/{{season}}/{{episode}}',cookies=cookies,headers=headers) + try: + video_data = response.json() # Assuming this is the JSON response containing video streams + + if 'streams' not in video_data: + print("Invalid JSON format: 'streams' key not found or incorrect structure") + return None + + streams = video_data['streams'] + + resolutions = {} + + for stream in streams: + resolution_name = stream['resolution']['name'].lower() # Convert resolution name to lowercase + url = stream['url'] + + # Remove everything after '.mp4' in the URL + mp4_index = url.find('.mp4') + if mp4_index != -1: + url = url[:mp4_index + 4] # +4 to include '.mp4' in the substring + + resolutions[resolution_name] = url + + return resolutions + + except KeyError as e: + print(f"KeyError: {e}") + return None + except json.JSONDecodeError as e: + print(f"JSONDecodeError: {e}") + return None + + except requests.RequestException as e: + print(f"Request error: {e}") + return None + + +# Example usage: Fetch video links + + +# Print the dictionary + + + + + +def search_imdb(showname,tmdba): + tmdba = str(tmdba) + query = f'https://altadefinizione-originale.com/api/search?search={showname}&page=1' + response = requests.get(query) + if response.status_code == 200: + data = response.json() + if 'data' in data: + for item in data['data']: + if item.get('tmdb_id') == tmdba: + slug = item.get('slug') + print(slug) + return slug + + + +def parse_links(resolution_links): + results = {} + if resolution_links: + print("Video links:") + for resolution, link in resolution_links.items(): + print(f"{resolution}: {link}") + results[resolution] = link + return results + else: + print("Failed to fetch video links") + + +def cool(imdb): + try: + type = "Cool" + general = is_movie(imdb) + ismovie = general[0] + imdb_id = general[1] + if ismovie == 0 : + season = int(general[2]) + episode = int(general[3]) + + if "tt" in imdb: + #Get showname + tmdba = get_TMDb_id_from_IMDb_id(imdb_id) + else: + tmdba = imdb_id.replace("tmdb:","") + + showname = get_info_tmdb(tmdba,ismovie,type) + + + slug = search_imdb(showname,tmdba) + if ismovie == 1: + season = None + episode = None + resolution_links = get_links(slug,episode,season,ismovie) + results = parse_links(resolution_links) + return results + elif ismovie == 0: + season = season -1 + episode = episode - 1 + resolution_links = get_links(slug,episode,season,ismovie) + results = parse_links(resolution_links) + return results + except Exception as e: + print("Cool Error") + return None \ No newline at end of file diff --git a/info.py b/info.py index 20bf65f..c9a61d9 100644 --- a/info.py +++ b/info.py @@ -5,7 +5,7 @@ import requests import config SC_FAST_SEARCH = config.SC_FAST_SEARCH TF_FAST_SEARCH = config.TF_FAST_SEARCH -TMDB_KEY= load_env() +TMDB_KEY,_= load_env() def get_info_tmdb(tmbda,ismovie,type): tmdb = TMDb() @@ -33,6 +33,8 @@ def get_info_tmdb(tmbda,ismovie,type): return showname,date else: return showname + elif type == "Cool": + return showname elif ismovie == 1: movie = Movie() @@ -54,7 +56,8 @@ def get_info_tmdb(tmbda,ismovie,type): return showname,date else: return showname - + elif type == "Cool": + return showname def get_info_imdb(imdb_id, ismovie, type): @@ -73,6 +76,8 @@ def get_info_imdb(imdb_id, ismovie, type): date = data['tv_results'][0]['first_air_date'] date = date.split("-")[0] return showname,date + elif type == "Cool": + return showname elif ismovie == 1: showname= data['movie_results'][0]['title'] @@ -85,6 +90,8 @@ def get_info_imdb(imdb_id, ismovie, type): date = date.split("-")[0] print("Real date",date) return showname,date + elif type == "Cool": + return showname diff --git a/loadenv.py b/loadenv.py index 16232d1..93bda20 100644 --- a/loadenv.py +++ b/loadenv.py @@ -1,6 +1,7 @@ import os import config - +import config +MYSTERIUS = config.MYSTERIUS dotenv = config.dotenv #You need to keep dotenv disabled on remote servers if dotenv == "1": @@ -10,4 +11,7 @@ if dotenv == "1": def load_env(): TMDB_KEY = os.getenv('TMDB_KEY') + if MYSTERIUS == "1": + MYSTERIUS_KEY = os.getenv('MYSTERIUS_KEY') + return TMDB_KEY, MYSTERIUS_KEY return TMDB_KEY \ No newline at end of file diff --git a/run.py b/run.py index 466a5ab..5ea421e 100644 --- a/run.py +++ b/run.py @@ -1,14 +1,17 @@ from flask import Flask, jsonify, abort from filmpertutti import filmpertutti from streamingcommunity import streaming_community +from tantifilm import tantifilm import json import config - FILMPERTUTTI = config.FILMPERTUTTI STREAMINGCOMMUNITY = config.STREAMINGCOMMUNITY +MYSTERIUS = config.MYSTERIUS +TUTTIFILM = config.TUTTIFILM HOST = config.HOST PORT = int(config.PORT) - +if MYSTERIUS == "1": + from cool import cool app = Flask(__name__) @@ -45,6 +48,11 @@ def addon_stream(type, id): if type not in MANIFEST['types']: abort(404) streams = {'streams': []} + if MYSTERIUS == "1": + results = cool(id) + if results: + for resolution, link in results.items(): + streams['streams'].append({'title': f'Mysterious {resolution}', 'url': link}) if STREAMINGCOMMUNITY == "1": url_streaming_community = streaming_community(id) print(url_streaming_community) @@ -57,7 +65,9 @@ def addon_stream(type, id): url_filmpertutti = filmpertutti(id) if url_filmpertutti is not None: streams['streams'].append({'title': 'Filmpertutti', 'url': url_filmpertutti}) - + if TUTTIFILM == "1": + url_tuttifilm = tantifilm(id) + streams['streams'].append({'title': 'Tantifilm', 'url': url_tuttifilm,'behaviorHints': {'proxyHeaders': {"request": {"Referer": "https://d000d.com/"}},'notWebReady': True}}) # If no streams were added, abort with a 404 error if not streams['streams']: abort(404) diff --git a/streamingcommunity.py b/streamingcommunity.py index a779653..8b7ecb7 100644 --- a/streamingcommunity.py +++ b/streamingcommunity.py @@ -102,53 +102,56 @@ def get_episode_link(episode_id,tid): def streaming_community(imdb): - general = is_movie(imdb) - ismovie = general[0] - imdb_id = general[1] - type = "StreamingCommunity" - if ismovie == 0 : - season = int(general[2]) - episode = int(general[3]) - #Check if fast search is enabled or disabled - if SC_FAST_SEARCH == "1": - if "tt" in imdb: - #Get showname - showname = get_info_imdb(imdb_id,ismovie,type) - n_season = None - else: - #I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled - n_season = None - #else just equals them - tmdba = imdb_id.replace("tmdb:","") - showname = get_info_tmdb(tmdba,ismovie,type) - elif SC_FAST_SEARCH == "0": - tmdba = get_TMDb_id_from_IMDb_id(imdb_id) - showname,n_season = get_info_tmdb(tmdba,ismovie,type) - #HERE THE CASE IF IT IS A MOVIE - else: - if "tt" in imdb: - #Get showname - n_season = None - showname = get_info_imdb(imdb_id,ismovie,type) + try: + general = is_movie(imdb) + ismovie = general[0] + imdb_id = general[1] + type = "StreamingCommunity" + if ismovie == 0 : + season = int(general[2]) + episode = int(general[3]) + #Check if fast search is enabled or disabled + if SC_FAST_SEARCH == "1": + if "tt" in imdb: + #Get showname + showname = get_info_imdb(imdb_id,ismovie,type) + n_season = None + else: + #I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled + n_season = None + #else just equals them + tmdba = imdb_id.replace("tmdb:","") + showname = get_info_tmdb(tmdba,ismovie,type) + elif SC_FAST_SEARCH == "0": + tmdba = get_TMDb_id_from_IMDb_id(imdb_id) + showname,n_season = get_info_tmdb(tmdba,ismovie,type) + #HERE THE CASE IF IT IS A MOVIE else: - #I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled - #else just equals them + if "tt" in imdb: + #Get showname n_season = None - tmdba = imdb_id.replace("tmdb:","") - showname = get_info_tmdb(tmdba,ismovie,type) + showname = get_info_imdb(imdb_id,ismovie,type) + else: + #I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled + #else just equals them + n_season = None + tmdba = imdb_id.replace("tmdb:","") + showname = get_info_tmdb(tmdba,ismovie,type) - showname = showname.replace(" ", "+").replace("–", "+").replace("—","+") - query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}' - tid,slug = search(query,n_season,ismovie) - if ismovie == 1: - #TID means temporaly ID - url = get_film(tid) - print(url) - return url - if ismovie == 0: - #Uid = URL ID - version = get_version() - episode_id = get_season_episode_id(tid,slug,season,episode,version) - url = get_episode_link(episode_id,tid) - print(url) - return url \ No newline at end of file + showname = showname.replace(" ", "+").replace("–", "+").replace("—","+") + query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}' + tid,slug = search(query,n_season,ismovie) + if ismovie == 1: + #TID means temporaly ID + url = get_film(tid) + print(url) + return url + if ismovie == 0: + #Uid = URL ID + version = get_version() + episode_id = get_season_episode_id(tid,slug,season,episode,version) + url = get_episode_link(episode_id,tid) + print(url) + return url + except Exception as e: + print("Nope It failed") \ No newline at end of file diff --git a/tantifilm.py b/tantifilm.py index 221d80d..40a1f90 100644 --- a/tantifilm.py +++ b/tantifilm.py @@ -87,7 +87,7 @@ def true_url(protect_link): rebobo = requests.get(url, headers=headers) real_url = f'{rebobo.text}123456789{match[2]}{real_time}' print(real_url) - return + return real_url else: print("No match found in the text.") return None @@ -99,57 +99,59 @@ def true_url(protect_link): #Get temporaly ID -def tuttifilm(imdb): - general = is_movie(imdb) - ismovie = general[0] - imdb_id = general[1] - type = "Tuttifilm" - if ismovie == 0 : - season = int(general[2]) - episode = int(general[3]) - if "tt" in imdb: - if TF_FAST_SEARCH == "0": - showname,date = get_info_imdb(imdb_id,ismovie,type) - elif TF_FAST_SEARCH == "1": - showname = get_info_imdb(imdb_id,ismovie,type) - date = None - else: - #else just equals them - tmdba = imdb_id.replace("tmdb:","") - if TF_FAST_SEARCH == "0": - showname = get_info_tmdb(tmdba,ismovie,type) - date = None - elif ismovie == 1: - season = None - episode = None - if "tt" in imdb: - #Get showname +def tantifilm(imdb): + try: + general = is_movie(imdb) + ismovie = general[0] + imdb_id = general[1] + type = "Tuttifilm" + if ismovie == 0 : + print("Series not supported yet") + return + season = int(general[2]) + episode = int(general[3]) + if "tt" in imdb: if TF_FAST_SEARCH == "0": showname,date = get_info_imdb(imdb_id,ismovie,type) - elif TF_FAST_SEARCH == "1": showname = get_info_imdb(imdb_id,ismovie,type) date = None - else: - - #else just equals them - tmdba = imdb_id.replace("tmdb:","") + else: + #else just equals them + tmdba = imdb_id.replace("tmdb:","") + if TF_FAST_SEARCH == "0": + showname = get_info_tmdb(tmdba,ismovie,type) + date = None + elif ismovie == 1: season = None episode = None - if TF_FAST_SEARCH == "0": - showname,date = get_info_tmdb(tmdba,ismovie,type) - date = None - elif TF_FAST_SEARCH == "1": - showname = get_info_tmdb(tmdba,ismovie,type) - date = None + if "tt" in imdb: + #Get showname + if TF_FAST_SEARCH == "0": + showname,date = get_info_imdb(imdb_id,ismovie,type) + + elif TF_FAST_SEARCH == "1": + showname = get_info_imdb(imdb_id,ismovie,type) + date = None + else: + + #else just equals themtantifilm("tt2096673") + + if TF_FAST_SEARCH == "0": + showname,date = get_info_tmdb(imdb,ismovie,type) + date = None + elif TF_FAST_SEARCH == "1": + showname = get_info_tmdb(imdb,ismovie,type) + date = None - tid = search(showname,ismovie,season,episode,date) - protect_link = get_protect_link(tid) - url = true_url(protect_link) - -tuttifilm("tt16426418") - + tid = search(showname,ismovie,season,episode,date) + protect_link = get_protect_link(tid) + url = true_url(protect_link) + return url + except Exception as e: + print("Tantifilm Error") +