Fixed Accurate search for streaming community
This commit is contained in:
+2
-2
@@ -3,7 +3,7 @@
|
|||||||
"StreamingCommunity": {
|
"StreamingCommunity": {
|
||||||
"enabled": "1",
|
"enabled": "1",
|
||||||
"domain": "boston",
|
"domain": "boston",
|
||||||
"fast_search": "1"
|
"fast_search": "0"
|
||||||
},
|
},
|
||||||
"Filmpertutti": {
|
"Filmpertutti": {
|
||||||
"enabled": "0",
|
"enabled": "0",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"fast_search": "0"
|
"fast_search": "0"
|
||||||
},
|
},
|
||||||
"Mysterius":{
|
"Mysterius":{
|
||||||
"enabled": "0"
|
"enabled": "1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"General":{
|
"General":{
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ def get_TMDb_id_from_IMDb_id(imdb_id):
|
|||||||
if tmbda['movie_results']:
|
if tmbda['movie_results']:
|
||||||
return tmbda['movie_results'][0]['id']
|
return tmbda['movie_results'][0]['id']
|
||||||
elif tmbda['tv_results']:
|
elif tmbda['tv_results']:
|
||||||
print(tmbda['tv_results'][0]['id'])
|
|
||||||
return tmbda['tv_results'][0]['id']
|
return tmbda['tv_results'][0]['id']
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
@@ -26,7 +26,10 @@ def get_info_tmdb(tmbda,ismovie,type):
|
|||||||
elif type == "StreamingCommunity":
|
elif type == "StreamingCommunity":
|
||||||
if SC_FAST_SEARCH == "0":
|
if SC_FAST_SEARCH == "0":
|
||||||
n_season = show.number_of_seasons
|
n_season = show.number_of_seasons
|
||||||
return showname,n_season
|
full_date = show.first_air_date
|
||||||
|
date = full_date.split("-")[0]
|
||||||
|
print(date)
|
||||||
|
return showname,date
|
||||||
else:
|
else:
|
||||||
return showname
|
return showname
|
||||||
elif type == "Tuttifilm":
|
elif type == "Tuttifilm":
|
||||||
|
|||||||
+34
-9
@@ -8,6 +8,7 @@ from convert import get_TMDb_id_from_IMDb_id
|
|||||||
from info import get_info_tmdb, is_movie, get_info_imdb
|
from info import get_info_tmdb, is_movie, get_info_imdb
|
||||||
import config
|
import config
|
||||||
import json
|
import json
|
||||||
|
import re
|
||||||
#Get domain
|
#Get domain
|
||||||
SC_DOMAIN= config.SC_DOMAIN
|
SC_DOMAIN= config.SC_DOMAIN
|
||||||
SC_FAST_SEARCH = config.SC_FAST_SEARCH
|
SC_FAST_SEARCH = config.SC_FAST_SEARCH
|
||||||
@@ -36,22 +37,44 @@ def get_version():
|
|||||||
version = "65e52dcf34d64173542cd2dc6b8bb75b"
|
version = "65e52dcf34d64173542cd2dc6b8bb75b"
|
||||||
return version
|
return version
|
||||||
|
|
||||||
def search(query,n_season,ismovie):
|
def search(query,date,ismovie):
|
||||||
#Do a request to get the ID of serie/move and it's slug in the URL
|
#Do a request to get the ID of serie/move and it's slug in the URL
|
||||||
response = requests.get(query).json()
|
response = requests.get(query).json()
|
||||||
for item in response['data']:
|
for item in response['data']:
|
||||||
tid = item['id']
|
tid = item['id']
|
||||||
slug = item['slug']
|
slug = item['slug']
|
||||||
idk = item['seasons_count']
|
type = item['type']
|
||||||
|
if type == "tv":
|
||||||
|
type = 0
|
||||||
|
elif type == "movie":
|
||||||
|
type = 1
|
||||||
|
if type == ismovie:
|
||||||
|
#Added a Check to see if the result is what it is supposed to be
|
||||||
if SC_FAST_SEARCH == "0":
|
if SC_FAST_SEARCH == "0":
|
||||||
if ismovie == 0:
|
if ismovie == 0:
|
||||||
seasons_count = item['seasons_count']
|
seasons_count = item['seasons_count']
|
||||||
if seasons_count == n_season:
|
#Do not ask me why but somewhy streaming community call the first air date the last air date
|
||||||
|
first_air_date = item['last_air_date']
|
||||||
|
if first_air_date:
|
||||||
|
first_air_year = first_air_date.split("-")[0]
|
||||||
|
if first_air_year == date:
|
||||||
|
return tid,slug
|
||||||
|
else:
|
||||||
|
response = requests.get ( f'https://streamingcommunity.boston/titles/{tid}-{slug}')
|
||||||
|
pattern = r'<div[^>]*class="features"[^>]*>.*?<span[^>]*>(.*?)<\/span>'
|
||||||
|
match = re.search(pattern, response.text)
|
||||||
|
print(match.group(1).split("-")[0])
|
||||||
|
first_air_year = match.group(1).split("-")[0]
|
||||||
|
date = int(date)
|
||||||
|
first_air_year = int(first_air_year)
|
||||||
|
if first_air_year == date:
|
||||||
return tid,slug
|
return tid,slug
|
||||||
elif ismovie == 1:
|
elif ismovie == 1:
|
||||||
return tid,slug
|
return tid,slug
|
||||||
elif SC_FAST_SEARCH == "1":
|
elif SC_FAST_SEARCH == "1":
|
||||||
return tid,slug
|
return tid,slug
|
||||||
|
else:
|
||||||
|
print("Couldn't find anything")
|
||||||
|
|
||||||
|
|
||||||
def get_film(tid):
|
def get_film(tid):
|
||||||
@@ -115,32 +138,32 @@ def streaming_community(imdb):
|
|||||||
if "tt" in imdb:
|
if "tt" in imdb:
|
||||||
#Get showname
|
#Get showname
|
||||||
showname = get_info_imdb(imdb_id,ismovie,type)
|
showname = get_info_imdb(imdb_id,ismovie,type)
|
||||||
n_season = None
|
date = None
|
||||||
else:
|
else:
|
||||||
#I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled
|
#I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled
|
||||||
n_season = None
|
date = None
|
||||||
#else just equals them
|
#else just equals them
|
||||||
tmdba = imdb_id.replace("tmdb:","")
|
tmdba = imdb_id.replace("tmdb:","")
|
||||||
showname = get_info_tmdb(tmdba,ismovie,type)
|
showname = get_info_tmdb(tmdba,ismovie,type)
|
||||||
elif SC_FAST_SEARCH == "0":
|
elif SC_FAST_SEARCH == "0":
|
||||||
tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
|
tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
|
||||||
showname,n_season = get_info_tmdb(tmdba,ismovie,type)
|
showname,date = get_info_tmdb(tmdba,ismovie,type)
|
||||||
#HERE THE CASE IF IT IS A MOVIE
|
#HERE THE CASE IF IT IS A MOVIE
|
||||||
else:
|
else:
|
||||||
if "tt" in imdb:
|
if "tt" in imdb:
|
||||||
#Get showname
|
#Get showname
|
||||||
n_season = None
|
date = None
|
||||||
showname = get_info_imdb(imdb_id,ismovie,type)
|
showname = get_info_imdb(imdb_id,ismovie,type)
|
||||||
else:
|
else:
|
||||||
#I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled
|
#I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled
|
||||||
#else just equals them
|
#else just equals them
|
||||||
n_season = None
|
date = None
|
||||||
tmdba = imdb_id.replace("tmdb:","")
|
tmdba = imdb_id.replace("tmdb:","")
|
||||||
showname = get_info_tmdb(tmdba,ismovie,type)
|
showname = get_info_tmdb(tmdba,ismovie,type)
|
||||||
|
|
||||||
showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
|
showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
|
||||||
query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}'
|
query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}'
|
||||||
tid,slug = search(query,n_season,ismovie)
|
tid,slug = search(query,date,ismovie)
|
||||||
if ismovie == 1:
|
if ismovie == 1:
|
||||||
#TID means temporaly ID
|
#TID means temporaly ID
|
||||||
url = get_film(tid)
|
url = get_film(tid)
|
||||||
@@ -155,3 +178,5 @@ def streaming_community(imdb):
|
|||||||
return url
|
return url
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Nope It failed")
|
print("Nope It failed")
|
||||||
|
|
||||||
|
streaming_community("tt0158552:3:2")
|
||||||
Reference in New Issue
Block a user