123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import os
- import json
- import requests
- import sqlite3
- from db import VVVVIDatabase
- from api import Api
- api = Api()
- stream_url = api.get_settings()
- if stream_url is None:
- print("VVVVID is not available at the moment")
- exit(1)
- vvvvidb = VVVVIDatabase("vvvvidb.sqlite3")
- api.login()
- if not vvvvidb.is_valid:
- # Database file not present
- # Create a new database
- vvvvidb.create()
- else:
- # Database file is already present
- # Since we have no information about series lenght prior to their pubblication
- # 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()
- last = 0
- # Scan all the episodes
- for i in range(last, min(last + 500, 1000)):
- print("Fetching...{}".format(i))
- info = api.get_info(i)
- if not info:
- continue
- seasons = api.get_seasons(i)
- for j in seasons:
- print("Found: {}".format(info['title']))
- 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)
- eps = api.format_episodes(j['season_id'], info['show_id'], episodes)
- print("Found {} episodes".format(len(eps)))
- vvvvidb.insert_episodes(eps)
|