diff --git a/api.py b/api.py index ab7fec8..8e6e4df 100644 --- a/api.py +++ b/api.py @@ -67,27 +67,28 @@ class Api(): return self.stream_url def login(self): - login = requests.get('https://www.vvvvid.it/user/login', headers={'User-Agent': Api.ua}) - self.conn_id = login.json()['data']['conn_id'] + login = requests.get('https://www.vvvvid.it/user/login', headers={'User-Agent': Api.ua}).json() + self.conn_id = login['data']['conn_id'] def get_info(self, show_id): info = requests.get('https://www.vvvvid.it/vvvvid/ondemand/' + str(show_id) + '/info/?conn_id=' + self.conn_id, headers={'User-Agent': Api.ua}) info.encoding = 'utf-8' - if info.json()['result'] == 'ok': - return info.json()['data'] + info = info.json() + if info['result'] == 'ok': + return info['data'] else: return False def get_seasons(self, show_id): - seasons = requests.get('https://www.vvvvid.it/vvvvid/ondemand/' + str(show_id) + '/seasons/?conn_id=' + self.conn_id, headers={'User-Agent': Api.ua}) - if seasons.json()['result'] == 'ok' and seasons.json()['data'] and seasons.json()['data'][0]['episodes']: - return seasons.json()['data'] + seasons = requests.get('https://www.vvvvid.it/vvvvid/ondemand/' + str(show_id) + '/seasons/?conn_id=' + self.conn_id, headers={'User-Agent': Api.ua}).json() + if seasons['result'] == 'ok' and seasons['data']: # and seasons['data'][0]['episodes']: + return seasons['data'] else: return [] def get_episodes(self, season_id, show_id): episodes = requests.get('https://www.vvvvid.it/vvvvid/ondemand/' + str(show_id) + '/season/' + str(season_id) + '?conn_id=' + self.conn_id, headers={'User-Agent': Api.ua}).json() - if episodes['result'] == 'ok' and episodes['data'] and episodes['data'][0]['embed_info']: + if episodes['result'] == 'ok' and episodes['data']: # and episodes['data'][0]['embed_info']: return episodes['data'] else: return [] @@ -97,7 +98,7 @@ class Api(): count = 0 for k in episodes: count += 1 - if k['embed_info']: + if k.get('embed_info'): if k['video_type'] == 'video/rcs': embed_info = self.ds(k['embed_info']) embed_info = 'https' + embed_info[4:30] + 'i' + embed_info[31:-12] + 'master.m3u8' @@ -109,5 +110,7 @@ class Api(): embed_info = self.ds(k['embed_info']) else: embed_info = self.ds(k['embed_info']) + else: + embed_info = "" eps.append((count, show_id, season_id, k['video_type'], embed_info)) return eps diff --git a/db.py b/db.py index 48c6ae7..31cda5e 100644 --- a/db.py +++ b/db.py @@ -34,7 +34,7 @@ class VVVVIDatabase(): con.close() # getting series in a useful format for later series = {} - for i,s in rows: + for i, s in rows: if series.get(i) is None: series[i] = [] series[i].append(s) @@ -49,12 +49,11 @@ class VVVVIDatabase(): con.close() # getting series in a useful format for later series = {} - for i,s in rows: + for i, s in rows: if series.get(i) is None: series[i] = [] series[i].append(s) - return series - + return series def insert_serie(self, serie): con = sqlite3.connect(self.path) @@ -80,4 +79,4 @@ class VVVVIDatabase(): except sqlite3.IntegrityError: # episodi gia' presenti pass - return False \ No newline at end of file + return False diff --git a/db_to_html.py b/db_to_html.py index 76c3c64..86a834b 100644 --- a/db_to_html.py +++ b/db_to_html.py @@ -3,7 +3,7 @@ import sqlite3 vvvvidb = "vvvvidb.sqlite3" -if not os.path.isfile(vvvvidb): +if not os.path.isfile(vvvvidb): print("{} file not found. Scrape the DB first using vvvvget.py".format(vvvvidb)) exit(1) @@ -23,10 +23,10 @@ out.write('''
Source Database