Fixed the english name and changed back to TMDB API
This commit is contained in:
+17
-5
@@ -7,7 +7,7 @@ import re
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import dateparser
|
import dateparser
|
||||||
from convert import get_TMDb_id_from_IMDb_id
|
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
|
from convert_date import convert_US_date
|
||||||
import logging
|
import logging
|
||||||
import config
|
import config
|
||||||
@@ -93,12 +93,23 @@ def filmpertutti(imdb):
|
|||||||
general = is_movie(imdb)
|
general = is_movie(imdb)
|
||||||
ismovie = general[0]
|
ismovie = general[0]
|
||||||
imdb_id = general[1]
|
imdb_id = general[1]
|
||||||
|
type = "Filmpertutti"
|
||||||
if ismovie == 0 :
|
if ismovie == 0 :
|
||||||
season = int(general[2])
|
season = int(general[2])
|
||||||
episode = int(general[3])
|
episode = int(general[3])
|
||||||
tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
|
if "tt" in imdb:
|
||||||
type = "Filmpertutti"
|
if ismovie == 0:
|
||||||
showname,date = get_info(tmdba,ismovie,type)
|
#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("—","+")
|
showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
|
||||||
#Build the query
|
#Build the query
|
||||||
query = f'https://filmpertutti.{FT_DOMAIN}/wp-json/wp/v2/posts?search={showname}&page=1&_fields=link,id'
|
query = f'https://filmpertutti.{FT_DOMAIN}/wp-json/wp/v2/posts?search={showname}&page=1&_fields=link,id'
|
||||||
@@ -122,4 +133,5 @@ def filmpertutti(imdb):
|
|||||||
#let's get delivery link, streaming link
|
#let's get delivery link, streaming link
|
||||||
streaming_link = get_true_link(real_link)
|
streaming_link = get_true_link(real_link)
|
||||||
print(streaming_link)
|
print(streaming_link)
|
||||||
return streaming_link
|
return streaming_link
|
||||||
|
filmpertutti("tt16426418")
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
from loadenv import load_env
|
from loadenv import load_env
|
||||||
from tmdbv3api import TMDb, Movie, TV
|
from tmdbv3api import TMDb, Movie, TV
|
||||||
from convert_date import convert_US_date, convert_IT_date
|
from convert_date import convert_US_date, convert_IT_date
|
||||||
|
import requests
|
||||||
TMDB_KEY= load_env()
|
TMDB_KEY= load_env()
|
||||||
|
|
||||||
def get_info(tmbda,ismovie,type):
|
def get_info_tmdb(tmbda,ismovie,type):
|
||||||
tmdb = TMDb()
|
tmdb = TMDb()
|
||||||
tmdb.api_key = f'{TMDB_KEY}'
|
tmdb.api_key = f'{TMDB_KEY}'
|
||||||
tmdb.language = 'it'
|
tmdb.language = 'it'
|
||||||
@@ -28,6 +29,33 @@ def get_info(tmbda,ismovie,type):
|
|||||||
return showname,date
|
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):
|
def is_movie(imdb_id):
|
||||||
if "tmdb:" in imdb_id:
|
if "tmdb:" in imdb_id:
|
||||||
imdb_id = imdb_id.replace("tmdb:","")
|
imdb_id = imdb_id.replace("tmdb:","")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from bs4 import BeautifulSoup,SoupStrainer
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import dateparser
|
import dateparser
|
||||||
from convert import get_TMDb_id_from_IMDb_id
|
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 config
|
||||||
import json
|
import json
|
||||||
#Get domain
|
#Get domain
|
||||||
@@ -99,16 +99,13 @@ def streaming_community(imdb):
|
|||||||
season = int(general[2])
|
season = int(general[2])
|
||||||
episode = int(general[3])
|
episode = int(general[3])
|
||||||
if "tt" in imdb:
|
if "tt" in imdb:
|
||||||
#If it is a imbd then conver it to tmbd
|
#Get showname
|
||||||
tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
|
showname = get_info_imdb(imdb_id,ismovie,"StreamingCommunity")
|
||||||
showname = requests.get(f'https://v3.sg.media-imdb.com/suggestion/a/{imdb_id}.json')
|
|
||||||
showname = showname.json()
|
|
||||||
showname = showname['d'][-1]['l']
|
|
||||||
else:
|
else:
|
||||||
#else just equals them
|
#else just equals them
|
||||||
tmdba = imdb_id.replace("tmdb:","")
|
tmdba = imdb_id.replace("tmdb:","")
|
||||||
type = "StreamingCommunity"
|
type = "StreamingCommunity"
|
||||||
showname = get_info(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)
|
tid,slug = search(query)
|
||||||
|
|||||||
Reference in New Issue
Block a user