From dbca6ac980383ff95a7ce77de0b118d16f5d3ecc Mon Sep 17 00:00:00 2001 From: UrloMythus Date: Sat, 13 Jul 2024 17:42:10 +0200 Subject: [PATCH] Some Fix --- README.md | 3 +- config.json | 6 +- config.py | 3 +- cool.py | 11 +++ info.py | 40 +++++++- streamingcommunity.py | 27 ++++- tantifilm.py | 222 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 297 insertions(+), 15 deletions(-) create mode 100644 cool.py create mode 100644 tantifilm.py diff --git a/README.md b/README.md index b1d5e63..f8e31fa 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,8 @@ To host this project with Hugging Face, go to the [linked](https://huggingface.c 8. Do not forget to add /manifest.json - 9. To update the remote server, you can either upload files manually, or you can connect the [repository locally](https://huggingface.co/docs/hub/en/repositories-getting-started) and use your file manager to do so. If you know how a Dockerfile works you could even clone the repository every time, although you will need to modify the config.json (by disabling both load_dotenv and FILMPERTUTTI). Plus remember that the README.MD of Hugging Face MUST NOT be overrided or the app won't run. + 9. To update the remote server, you can either upload files manually, or you can connect the [repository locally](https://huggingface.co/docs/hub/en/repositories-getting-started) and use your file manager to do so. If you know how a Dockerfile works you could even clone the repository every time, although you will need to modify the config.json (by disabling both load_dotenv and FILMPERTUTTI). Plus remember that the README.MD of Hugging Face MUST NOT be changed or the app won't run. +If you just want to syncronize with the public instance then there is a button in the settings to do so. diff --git a/config.json b/config.json index f7d91fa..9b77ff0 100644 --- a/config.json +++ b/config.json @@ -1,15 +1,15 @@ { "Siti": { "StreamingCommunity": { - "enabled": "1", + "enabled": "0", "domain": "boston", - "fast_search": "0" + "fast_search": "1" }, "Filmpertutti": { "enabled": "1", "domain": "makeup" }, - "Tantifilm":{ + "Tuttifilm":{ "enabled": "1", "domain": "bond", "fast_search": "0" diff --git a/config.py b/config.py index 634b59d..833bbda 100644 --- a/config.py +++ b/config.py @@ -10,10 +10,11 @@ with open('config.json') as f: SITE = config["Siti"] FT_DOMAIN = SITE["Filmpertutti"]['domain'] SC_DOMAIN = SITE["StreamingCommunity"]['domain'] -TF_DOMAIN = SITE["Filmpertutti"]['enabled'] +TF_DOMAIN = SITE["Tuttifilm"]['enabled'] FILMPERTUTTI = SITE["Filmpertutti"]['enabled'] STREAMINGCOMMUNITY = SITE["StreamingCommunity"]['enabled'] SC_FAST_SEARCH = SITE["StreamingCommunity"]['fast_search'] +TF_FAST_SEARCH = SITE["Tuttifilm"]['fast_search'] #General GENERAL = config['General'] dotenv = GENERAL["load_env"] diff --git a/cool.py b/cool.py new file mode 100644 index 0000000..0a36573 --- /dev/null +++ b/cool.py @@ -0,0 +1,11 @@ +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 + diff --git a/info.py b/info.py index afb6227..20bf65f 100644 --- a/info.py +++ b/info.py @@ -4,6 +4,7 @@ from convert_date import convert_US_date, convert_IT_date import requests import config SC_FAST_SEARCH = config.SC_FAST_SEARCH +TF_FAST_SEARCH = config.TF_FAST_SEARCH TMDB_KEY= load_env() def get_info_tmdb(tmbda,ismovie,type): @@ -22,19 +23,38 @@ def get_info_tmdb(tmbda,ismovie,type): if SC_FAST_SEARCH == "0": n_season = show.number_of_seasons return showname,n_season + else: + return showname + elif type == "Tuttifilm": + if TF_FAST_SEARCH == "0": + date = show.first_air_date + date = date.split("-")[0] + print("Real date",date) + return showname,date + else: + return showname - else: + elif ismovie == 1: movie = Movie() show= movie.details(tmbda) showname= show.title #Get all release dates - date = show.release_dates if type == "Filmpertutti": + date = show.release_dates #GET US RELEASE DATE because filmpertutti somewhy uses US release date date = convert_US_date(date) - return showname,date - - + return showname,date + elif type == "StreamingCommunity": + return showname + elif type == "Tuttifilm": + if TF_FAST_SEARCH == "0": + date = show.release_date + date = date.split("-")[0] + print("Real date",date) + return showname,date + else: + return showname + def get_info_imdb(imdb_id, ismovie, type): @@ -49,6 +69,10 @@ def get_info_imdb(imdb_id, ismovie, type): return showname, date elif type == "StreamingCommunity": return showname + elif type == "Tuttifilm": + date = data['tv_results'][0]['first_air_date'] + date = date.split("-")[0] + return showname,date elif ismovie == 1: showname= data['movie_results'][0]['title'] @@ -56,6 +80,12 @@ def get_info_imdb(imdb_id, ismovie, type): return elif type == "StreamingCommunity": return showname + elif type == "Tuttifilm": + date = data['movie_results'][0]['release_date'] + date = date.split("-")[0] + print("Real date",date) + return showname,date + diff --git a/streamingcommunity.py b/streamingcommunity.py index e7db9a2..a779653 100644 --- a/streamingcommunity.py +++ b/streamingcommunity.py @@ -36,15 +36,19 @@ def get_version(): version = "65e52dcf34d64173542cd2dc6b8bb75b" return version -def search(query,n_season): +def search(query,n_season,ismovie): #Do a request to get the ID of serie/move and it's slug in the URL response = requests.get(query).json() for item in response['data']: tid = item['id'] slug = item['slug'] - number_of_seasons = item['seasons_count'] + idk = item['seasons_count'] if SC_FAST_SEARCH == "0": - if number_of_seasons == n_season: + if ismovie == 0: + seasons_count = item['seasons_count'] + if seasons_count == n_season: + return tid,slug + elif ismovie == 1: return tid,slug elif SC_FAST_SEARCH == "1": return tid,slug @@ -119,10 +123,23 @@ def streaming_community(imdb): 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) + 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) + 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) + tid,slug = search(query,n_season,ismovie) if ismovie == 1: #TID means temporaly ID url = get_film(tid) diff --git a/tantifilm.py b/tantifilm.py new file mode 100644 index 0000000..221d80d --- /dev/null +++ b/tantifilm.py @@ -0,0 +1,222 @@ +import requests +from bs4 import BeautifulSoup,SoupStrainer +import re +import time +from info import is_movie,get_info_imdb,get_info_tmdb +import config +TF_FAST_SEARCH = config.TF_FAST_SEARCH +TF_DOMAIN = config.TF_DOMAIN + + +##FOR NOW ONLY MOVIES WORK, I HOPE I CAN FIX SERIES +def search(showname,ismovie,season,episode,date): + url = f'https://www.tanti.bond/search/{showname}' + response = requests.get(url) + soup = BeautifulSoup(response.text, "lxml") + if ismovie == 1: + all_link = soup.select('#movies .col .list-media') + for link in all_link: + url = link['href'] + response = requests.get(url) + pattern = r'Data di rilascio\s*\s*
\s*(\d{4})\s*
' + found_date = re.search(pattern, response.text) + release_date = str(found_date.group(1)) + print(release_date) + if release_date == date: + tid= url.split('-')[1] + print(tid) + #Return URL and even the soup so I can use it later + #I try to get doodstream link inside this function so I do not have to get again the response + print(url) + return tid + elif ismovie == 0: + all_link = soup.select('#series .col .list-media') + for link in all_link: + base_url = link['href'] + url = f'{base_url}-{season}-season-{episode}-episode' + response = requests.get(url) + pattern = r'Data di rilascio\s*\s*
\s*(\d{4})\s*
' + found_date = re.search(pattern, response.text) + release_date = str(found_date.group(1)) + if release_date == date: + print("RELEASE DATE IS EQUAL") + tid= url.split('-')[1] + print(tid) + #I try to get doodstream link inside this function so I do not have to get again the response + return tid + + + +def get_protect_link(id): + #Get the link where the Iframe is located, which contains the doodstream url kind of. + response = requests.get(f"https://p.hdplayer.casa/myadmin/play.php?id={id}") + soup = BeautifulSoup(response.text, "lxml", parse_only=SoupStrainer('iframe')) + print(soup) + protect_link = soup.iframe['src'] + print("HERE PROTECT_LINK",protect_link) + return protect_link + + + +def true_url(protect_link): + # Define headers + headers = { + "Range": "bytes=0-", + "Referer": "https://d000d.com/", + } + response = requests.get(protect_link) + link = response.url + #Get the ID + doodstream_id = link.rsplit('/e/', 1)[-1] + # Make a GET request + + if response.status_code == 200: + # Get unique timestamp for the request + real_time = str(int(time.time())) + + # Regular Expression Pattern for the match + pattern = r"(\/pass_md5\/.*?)'.*(\?token=.*?expiry=)" + + # Find the match + match = re.search(pattern, response.text, re.DOTALL) + + # If a match was found + if match: + # Create real link (match[0] includes all matched elements) + url =f'https://d000d.com{match[1]}' + rebobo = requests.get(url, headers=headers) + real_url = f'{rebobo.text}123456789{match[2]}{real_time}' + print(real_url) + return + else: + print("No match found in the text.") + return None + + print("Error: Could not get the response.") + return None + + + + +#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 + 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:","") + 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 + + tid = search(showname,ismovie,season,episode,date) + protect_link = get_protect_link(tid) + url = true_url(protect_link) + +tuttifilm("tt16426418") + + + + + + + + + + + + + +#OLD SEARC THAT DOESN't CHECK THE DATE +def mamma(showname,ismovie,season,episode): + url = f'https://www.tanti.bond/search/{showname}' + response = requests.get(url) + soup = BeautifulSoup(response.text, "lxml") + if ismovie == 1: + first_link = soup.select_one('#movies .col .list-media') + url = first_link['href'] + return url + elif ismovie == 0: + first_link = soup.select_one('#series .col .list-media') + base_url = first_link['href'] + url = f'{base_url}-{season}-{episode}' + print(url) + return url + + + + + + + + + + + + + + + + +def searcht(showname,ismovie,season,episode): + url = f'https://www.tanti.bond/search/{showname}' + response = requests.get(url) + soup = BeautifulSoup(response.text, "lxml") + date = "2020" + if ismovie == 1: + all_link = soup.select('#movies .col .list-media') + for link in all_link: + url = link['href'] + response = requests.get(url) + info_soup = BeautifulSoup(response.text, "lxml") + release_date= info_soup.select('div.video-attr div.text')[4].text.strip() + if release_date == date: + print("WOW") + #Return URL and even the soup so I can use it later + return url,info_soup + elif ismovie == 0: + all_link = soup.select('#series .col .list-media') + for link in all_link: + base_url = link['href'] + url = f'{base_url}-{season}-season-{episode}-episode' + response = requests.get(url) + info_soup = BeautifulSoup(response.text, "lxml") + release_date= info_soup.select('div.video-attr div.text')[4].text.strip() + if release_date == date: + print("RELEASE DATE IS EQUAL") + #Return URL and even the soup so I can use it later + return url,info_soup \ No newline at end of file