File size: 4,552 Bytes
1f9aed5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32b9f1d
 
 
 
 
 
 
 
 
 
1f9aed5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32b9f1d
 
 
 
 
 
 
 
 
 
1f9aed5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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
TF_FAST_SEARCH = config.TF_FAST_SEARCH
MYSTERIUS = config.MYSTERIUS
if MYSTERIUS == "1":
    TMDB_KEY,_= load_env()
else:
    TMDB_KEY= load_env()

def get_info_tmdb(tmbda,ismovie,type):
    tmdb = TMDb()
    tmdb.api_key = f'{TMDB_KEY}'
    tmdb.language = 'it'
    if ismovie == 0:
        tv = TV()
        show= tv.details(tmbda)
        showname = show.name
        if type == "Filmpertutti":
            date= show.first_air_date
            print("Real date",date)
            return showname,date
        elif type == "StreamingCommunity":
            if SC_FAST_SEARCH == "0":
                n_season = show.number_of_seasons
                full_date = show.first_air_date
                date = full_date.split("-")[0]
                print(date)
                return showname,date
            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
        elif type == "Cool":
            return showname
        elif type == "LordChannel":
            date = show.first_air_date
            date = date.split("-")[0]
            print("Real date",date)
       	    return showname,date
        elif type == "StreamingWatch":
            date = show.first_air_date
            date = date.split("-")[0]
            print("Real date",date)
            return showname,date
    
    elif ismovie == 1:
        movie = Movie()
        show= movie.details(tmbda)
        showname= show.title
        #Get all 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
        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
        elif type == "Cool":
            return showname
        elif type == "LordChannel":
            date = show.release_date
            date = date.split("-")[0]
            print("Real date",date)
            return showname,date
        elif type == "StreamingWatch":
            date = show.release_date
            date = date.split("-")[0]
            print("Real date",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 type == "Tuttifilm":
            if TF_FAST_SEARCH == "0":
                date = data['tv_results'][0]['first_air_date']
                date = date.split("-")[0]
                return showname,date
            elif TF_FAST_SEARCH == "1":
                return showname
        elif type == "Cool":
            return showname

    elif ismovie == 1:
        showname= data['movie_results'][0]['title']
        if type == "Filmpertutti":
            return
        elif type == "StreamingCommunity":
            return showname
        elif type == "Tuttifilm":
            date = data['movie_results'][0]['release_date']
            date = date.split("-")[0]
            return showname,date
        elif type == "Cool":
            return showname

            




def is_movie(imdb_id):
    if "tmdb:" in imdb_id:
        imdb_id = imdb_id.replace("tmdb:","")
    if ":"  in imdb_id:
        season = imdb_id.split(":")[1]
        episode = imdb_id.split(":")[-1]
        ismovie = 0
        imdb_id = imdb_id.split(":")[0]
        return ismovie,imdb_id,season,episode
    else:
        ismovie = 1
        return ismovie,imdb_id