|
@@ -1,7 +1,3 @@
|
|
|
-import os
|
|
|
-import json
|
|
|
-import requests
|
|
|
-import sqlite3
|
|
|
from db import VVVVIDatabase
|
|
|
from api import Api
|
|
|
|
|
@@ -13,6 +9,8 @@ if stream_url is None:
|
|
|
|
|
|
vvvvidb = VVVVIDatabase("vvvvidb.sqlite3")
|
|
|
api.login()
|
|
|
+last = 0
|
|
|
+smax = 1000
|
|
|
|
|
|
if not vvvvidb.is_valid:
|
|
|
# Database file not present
|
|
@@ -24,65 +22,44 @@ else:
|
|
|
# We scan all the older id to see if there are new episodes, then we scan every id greater then the last one
|
|
|
ids = vvvvidb.series_id()
|
|
|
|
|
|
- """
|
|
|
for i in ids.keys():
|
|
|
print("Fetching old...{}".format(i))
|
|
|
- print(ids.get(i))
|
|
|
info = api.get_info(i)
|
|
|
if not info:
|
|
|
continue
|
|
|
seasons = api.get_seasons(i)
|
|
|
for j in seasons:
|
|
|
- serie = (info['show_id'], info['title'], j['season_id'], j['name'])
|
|
|
-
|
|
|
if j['season_id'] not in ids.get(i):
|
|
|
# We found a new season for an old show
|
|
|
- print("Found: {}".format(info['title']))
|
|
|
-
|
|
|
- if not vvvvidb.insert_serie(serie):
|
|
|
- continue
|
|
|
-
|
|
|
- episodes = get_episodes(j['season_id'], i, conn_id)
|
|
|
- if not episodes:
|
|
|
- continue
|
|
|
- format_episodes(info, j, episodes, vvvvid_stream_url)
|
|
|
- print("Found {} episodes".format(len(eps)))
|
|
|
-
|
|
|
- vvvvidb.insert_episode(eps)
|
|
|
- else:
|
|
|
- # Check if there are new episodes for old season
|
|
|
- episodes = get_episodes(j['season_id'], i, conn_id)
|
|
|
- if not episodes:
|
|
|
+ if not vvvvidb.insert_serie((info['show_id'], info['title'], j['season_id'], j['name'])):
|
|
|
continue
|
|
|
- eps = format_episodes(info, j, episodes, vvvvid_stream_url)
|
|
|
- print("Found {} episodes".format(len(eps)))
|
|
|
|
|
|
- vvvvidb.insert_episodes(eps)
|
|
|
+ # New episodes for a new or old season
|
|
|
+ episodes = api.get_episodes(j['season_id'], i)
|
|
|
+ eps = api.format_episodes(j['season_id'], info['show_id'], episodes)
|
|
|
+ print("Found {} episodes".format(len(eps)))
|
|
|
+ vvvvidb.insert_episodes(eps)
|
|
|
|
|
|
- last = i
|
|
|
+ last = i + 1
|
|
|
+ smax = 200
|
|
|
|
|
|
print("Resuming from...{}".format(last))
|
|
|
- exit()
|
|
|
- """
|
|
|
|
|
|
-last = 0
|
|
|
# Scan all the episodes
|
|
|
-for i in range(last, min(last + 500, 1000)):
|
|
|
+for i in range(last, last + smax):
|
|
|
print("Fetching...{}".format(i))
|
|
|
info = api.get_info(i)
|
|
|
if not info:
|
|
|
continue
|
|
|
seasons = api.get_seasons(i)
|
|
|
for j in seasons:
|
|
|
- serie = (info['show_id'], info['title'], j['season_id'], j['name'])
|
|
|
print("Found: {}".format(info['title']))
|
|
|
|
|
|
- if not vvvvidb.insert_serie(serie):
|
|
|
+ if not vvvvidb.insert_serie((info['show_id'], info['title'], j['season_id'], j['name'])):
|
|
|
print("Serie already present")
|
|
|
continue
|
|
|
|
|
|
episodes = api.get_episodes(j['season_id'], i)
|
|
|
- print(len(episodes))
|
|
|
eps = api.format_episodes(j['season_id'], info['show_id'], episodes)
|
|
|
print("Found {} episodes".format(len(eps)))
|
|
|
vvvvidb.insert_episodes(eps)
|