Fixed the english name and changed back to TMDB API
This commit is contained in:
+16
-4
@@ -7,7 +7,7 @@ import re
|
||||
from datetime import datetime
|
||||
import dateparser
|
||||
from convert import get_TMDb_id_from_IMDb_id
|
||||
from info import get_info, is_movie
|
||||
from info import get_info_tmdb, is_movie, get_info_imdb
|
||||
from convert_date import convert_US_date
|
||||
import logging
|
||||
import config
|
||||
@@ -93,12 +93,23 @@ def filmpertutti(imdb):
|
||||
general = is_movie(imdb)
|
||||
ismovie = general[0]
|
||||
imdb_id = general[1]
|
||||
type = "Filmpertutti"
|
||||
if ismovie == 0 :
|
||||
season = int(general[2])
|
||||
episode = int(general[3])
|
||||
tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
|
||||
type = "Filmpertutti"
|
||||
showname,date = get_info(tmdba,ismovie,type)
|
||||
if "tt" in imdb:
|
||||
if ismovie == 0:
|
||||
#Get showname and date
|
||||
showname,date = get_info_imdb(imdb_id,ismovie,type)
|
||||
else:
|
||||
#THIS IS needed cause the only way to get all releases dates is by giving a tmdb ID not a IMDB
|
||||
tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
|
||||
showname,date = get_info_tmdb(tmdba,ismovie,type)
|
||||
|
||||
elif "tmdb" in imdb:
|
||||
#Get showname and date
|
||||
tmdba = imdb_id.replace("tmdb:","")
|
||||
showname,date = get_info_tmdb(tmdba,ismovie,type)
|
||||
showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
|
||||
#Build the query
|
||||
query = f'https://filmpertutti.{FT_DOMAIN}/wp-json/wp/v2/posts?search={showname}&page=1&_fields=link,id'
|
||||
@@ -123,3 +134,4 @@ def filmpertutti(imdb):
|
||||
streaming_link = get_true_link(real_link)
|
||||
print(streaming_link)
|
||||
return streaming_link
|
||||
filmpertutti("tt16426418")
|
||||
@@ -1,9 +1,10 @@
|
||||
from loadenv import load_env
|
||||
from tmdbv3api import TMDb, Movie, TV
|
||||
from convert_date import convert_US_date, convert_IT_date
|
||||
import requests
|
||||
TMDB_KEY= load_env()
|
||||
|
||||
def get_info(tmbda,ismovie,type):
|
||||
def get_info_tmdb(tmbda,ismovie,type):
|
||||
tmdb = TMDb()
|
||||
tmdb.api_key = f'{TMDB_KEY}'
|
||||
tmdb.language = 'it'
|
||||
@@ -28,6 +29,33 @@ def get_info(tmbda,ismovie,type):
|
||||
return showname,date
|
||||
|
||||
|
||||
|
||||
|
||||
def get_info_imdb(imdb_id, ismovie, type):
|
||||
|
||||
resp = requests.get(f'https://api.themoviedb.org/3/find/{imdb_id}?api_key={TMDB_KEY}&language=it&external_source=imdb_id')
|
||||
data = resp.json()
|
||||
if ismovie == 0:
|
||||
showname = data['tv_results'][0]['name']
|
||||
if type == "Filmpertutti":
|
||||
date= data['tv_results'][0]['first_air_date']
|
||||
print("Real date",date)
|
||||
return showname, date
|
||||
elif type == "StreamingCommunity":
|
||||
return showname
|
||||
|
||||
elif ismovie == 1:
|
||||
showname= data['movie_results'][0]['title']
|
||||
if type == "Filmpertutti":
|
||||
return
|
||||
elif type == "StreamingCommunity":
|
||||
return showname
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def is_movie(imdb_id):
|
||||
if "tmdb:" in imdb_id:
|
||||
imdb_id = imdb_id.replace("tmdb:","")
|
||||
|
||||
@@ -5,7 +5,7 @@ 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, is_movie
|
||||
from info import get_info_tmdb, is_movie, get_info_imdb
|
||||
import config
|
||||
import json
|
||||
#Get domain
|
||||
@@ -99,16 +99,13 @@ def streaming_community(imdb):
|
||||
season = int(general[2])
|
||||
episode = int(general[3])
|
||||
if "tt" in imdb:
|
||||
#If it is a imbd then conver it to tmbd
|
||||
tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
|
||||
showname = requests.get(f'https://v3.sg.media-imdb.com/suggestion/a/{imdb_id}.json')
|
||||
showname = showname.json()
|
||||
showname = showname['d'][-1]['l']
|
||||
#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(tmdba,ismovie,type)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user