Update update_wiki.py

This commit is contained in:
Sarah 2022-12-23 16:38:52 +00:00
parent 08c22b1277
commit 732b32f39b
1 changed files with 10 additions and 10 deletions

View File

@ -1,5 +1,5 @@
from wiki_pages import FilmsByCountry, FilmsByReference, FilmsByYear, HiddenThemes, KeywordScores, ViewingsCsv
from vcinema_utils import VCinemaUtils
from vcinema_utils.VCinemaUtils import *
import argparse
import json
@ -12,7 +12,7 @@ def update_wiki(token_id, token_secret, update_csv, pages):
ViewingsCsv.update_viewings_csv(token_id, token_secret)
print("Getting viewings")
viewings = VCinemaUtils.get_vcinema_viewings(token_id, token_secret)
films = get_vcinema_films(token_id, token_secret)
update_films_by_year = 'years' in pages
update_films_by_country = 'countries' in pages
@ -30,26 +30,26 @@ def update_wiki(token_id, token_secret, update_csv, pages):
if update_film_references or update_hidden_themes or update_keyword_scores:
data_fields.append("keywords")
viewing_count = len(viewings)
with IncrementalBar('Retrieving movie data', max=viewing_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
VCinemaUtils.add_imdb_data_to_viewings(viewings, data_fields, bar)
films_count = len(films)
with IncrementalBar('Retrieving movie data', max=films_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
add_imdb_data_to_films(films, data_fields, bar)
print("Processing viewing data")
if update_films_by_year:
films_by_year = FilmsByYear.get_films_by_year(viewings)
films_by_year = FilmsByYear.get_films_by_year(films)
FilmsByYear.update_page(token_id, token_secret, films_by_year)
if update_films_by_country:
films_by_country = FilmsByCountry.get_films_by_country(viewings)
films_by_country = FilmsByCountry.get_films_by_country(films)
FilmsByCountry.update_page(token_id, token_secret, films_by_country)
if update_film_references:
films_by_reference = FilmsByReference.get_films_by_reference(viewings)
films_by_reference = FilmsByReference.get_films_by_reference(films)
FilmsByReference.update_page(token_id, token_secret, films_by_reference)
if update_hidden_themes:
hidden_themes = HiddenThemes.get_hidden_themes(viewings, token_id, token_secret)
hidden_themes = HiddenThemes.get_hidden_themes(films, token_id, token_secret)
HiddenThemes.update_page(token_id, token_secret, hidden_themes)
if update_keyword_scores:
keyword_scores = KeywordScores.get_keyword_scores(viewings)
keyword_scores = KeywordScores.get_keyword_scores(films)
KeywordScores.update_page(token_id, token_secret, keyword_scores)
print("Done!")