Exemple #1
0
def test_get_movies(mocker):
    create_test_tables()
    db = MySQLDatabase(schema='qmdb_test', env='test')
    crit_scraper = CritickerScraper()
    crit_scraper.get_movies(db, start_popularity=8)
    save_movies_call_args = db.save_movies.call_args_list[0][0]
    assert save_movies_call_args[0] == [1, 1, 1]
    assert crit_scraper.get_movies_of_popularity.call_args_list[0][1] ==\
           {'debug': False, 'min_year': 2013, 'popularity': 10}
    assert crit_scraper.get_movies_of_popularity.call_args_list[1][1] ==\
           {'debug': False, 'min_year': 2016, 'popularity': 9}
    assert crit_scraper.get_movies_of_popularity.call_args_list[2][1] ==\
           {'debug': False, 'min_year': 2018, 'popularity': 8}
    remove_test_tables(db)
Exemple #2
0
from qmdb.database.database import MySQLDatabase
from qmdb.interfaces.omdb import OMDBScraper
from qmdb.interfaces.criticker import CritickerScraper
from qmdb.interfaces.updater import Updater
from qmdb.model.predictions import RatingModeler
from qmdb.interfaces.netflix import NetflixScraper
import time

if __name__ == "__main__":
    db = MySQLDatabase(from_scratch=False)
    omdb_scraper = OMDBScraper()
    crit_scraper = CritickerScraper(user='******')
    updater = Updater()
    modeler = RatingModeler(db)
    netflix_scraper = NetflixScraper(db)

    while True:
        print("\nRefreshing movie information from Criticker, IMDb and OMDB\n")
        time0 = time.time()
        while time.time() - time0 <= 12 * 3600:
            updater.update_movies(db, n=30, weibull_lambda=3)
        crit_scraper.get_movies(db, start_popularity=2)
        netflix_scraper.get_genre_ids()
        netflix_scraper.get_movies_for_genres()
        crit_scraper.get_ratings(db)
        modeler.get_predictions()