From 0e13ada65f0947de75d8c20be9f74a6b2ac0aa24 Mon Sep 17 00:00:00 2001 From: UrloMythus Date: Thu, 11 Jul 2024 21:07:46 +0200 Subject: [PATCH] Added Accurate Search for Streaming Community but for series --- README.md | 2 +- config.json | 5 +++-- config.py | 1 + info.py | 11 ++++++++--- streamingcommunity.py | 36 +++++++++++++++++++++++++----------- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ffd5563..b1d5e63 100644 --- a/README.md +++ b/README.md @@ -237,7 +237,7 @@ In the repo there is a config.json that you can modify to change some aspects of |-------------------------|---| | Domain | The domain of the site, must be a string | |enabled | If the site is enabled or not. "1" means true. "0" means false. Remember there is no point in enabling filmpertutti on a remote server since it's IP-LOCKED| -|fast_search|"1" for enabled, "0" for disabled. It enables a faster search for TuttiFilm Provider but in case there are two movies/series with the exactly same name then it might take the wrong one| +|fast_search|"1" for enabled, "0" for disabled. It enables a faster search for TantiFilm Provider but in case there are two movies/series with the exactly same name then it might take the wrong one| |load_env|Put "1" if enabled, "0" if disabled. It needs to be enable if you need to load a .env file. On remote hosting services, like Hugging Face or Render, it needs to be disabled. | |HOST| The host for the Flask APP| |PORT| The port for the Flask APP. Default: 8080 | diff --git a/config.json b/config.json index 6d27530..f7d91fa 100644 --- a/config.json +++ b/config.json @@ -2,13 +2,14 @@ "Siti": { "StreamingCommunity": { "enabled": "1", - "domain": "boston" + "domain": "boston", + "fast_search": "0" }, "Filmpertutti": { "enabled": "1", "domain": "makeup" }, - "Tuttifilm":{ + "Tantifilm":{ "enabled": "1", "domain": "bond", "fast_search": "0" diff --git a/config.py b/config.py index b295f6e..634b59d 100644 --- a/config.py +++ b/config.py @@ -13,6 +13,7 @@ SC_DOMAIN = SITE["StreamingCommunity"]['domain'] TF_DOMAIN = SITE["Filmpertutti"]['enabled'] FILMPERTUTTI = SITE["Filmpertutti"]['enabled'] STREAMINGCOMMUNITY = SITE["StreamingCommunity"]['enabled'] +SC_FAST_SEARCH = SITE["StreamingCommunity"]['fast_search'] #General GENERAL = config['General'] dotenv = GENERAL["load_env"] diff --git a/info.py b/info.py index 4e9fc9b..afb6227 100644 --- a/info.py +++ b/info.py @@ -2,6 +2,8 @@ from loadenv import load_env from tmdbv3api import TMDb, Movie, TV from convert_date import convert_US_date, convert_IT_date import requests +import config +SC_FAST_SEARCH = config.SC_FAST_SEARCH TMDB_KEY= load_env() def get_info_tmdb(tmbda,ismovie,type): @@ -14,9 +16,13 @@ def get_info_tmdb(tmbda,ismovie,type): showname = show.name if type == "Filmpertutti": date= show.first_air_date - elif type == "StreamingCommunity": - date = show.last_air_date print("Real date",date) + return showname,date + elif type == "StreamingCommunity": + if SC_FAST_SEARCH == "0": + n_season = show.number_of_seasons + return showname,n_season + else: movie = Movie() show= movie.details(tmbda) @@ -55,7 +61,6 @@ def get_info_imdb(imdb_id, ismovie, type): - def is_movie(imdb_id): if "tmdb:" in imdb_id: imdb_id = imdb_id.replace("tmdb:","") diff --git a/streamingcommunity.py b/streamingcommunity.py index 18242f8..e7db9a2 100644 --- a/streamingcommunity.py +++ b/streamingcommunity.py @@ -10,6 +10,7 @@ import config import json #Get domain SC_DOMAIN= config.SC_DOMAIN +SC_FAST_SEARCH = config.SC_FAST_SEARCH 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', @@ -35,13 +36,18 @@ def get_version(): version = "65e52dcf34d64173542cd2dc6b8bb75b" return version -def search(query): +def search(query,n_season): #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'] - return tid,slug + number_of_seasons = item['seasons_count'] + if SC_FAST_SEARCH == "0": + if number_of_seasons == n_season: + return tid,slug + elif SC_FAST_SEARCH == "1": + return tid,slug def get_film(tid): @@ -95,20 +101,28 @@ 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]) - if "tt" in imdb: - #Get showname - showname = get_info_imdb(imdb_id,ismovie,"StreamingCommunity") - else: - #else just equals them - tmdba = imdb_id.replace("tmdb:","") - type = "StreamingCommunity" - showname = get_info_tmdb(tmdba,ismovie,type) + #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) showname = showname.replace(" ", "+").replace("–", "+").replace("—","+") query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}' - tid,slug = search(query) + tid,slug = search(query,n_season) if ismovie == 1: #TID means temporaly ID url = get_film(tid)