fix arg and refactor
This commit is contained in:
parent
71402fb6b7
commit
cef9dddac4
|
@ -33,46 +33,25 @@ def update_wiki(token_id, token_secret, update_csv, pages):
|
|||
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)
|
||||
|
||||
update_page_count = sum([update_films_by_year, update_films_by_country, update_film_references,
|
||||
update_hidden_themes, update_keyword_scores])
|
||||
print("Processing viewing data")
|
||||
|
||||
with IncrementalBar('Processing viewing data', max=update_page_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
|
||||
if update_films_by_year:
|
||||
films_by_year = FilmsByYear.get_films_by_year(viewings)
|
||||
bar.next()
|
||||
if update_films_by_country:
|
||||
films_by_country = FilmsByCountry.get_films_by_country(viewings)
|
||||
bar.next()
|
||||
if update_film_references:
|
||||
films_by_reference = FilmsByReference.get_films_by_reference(viewings)
|
||||
bar.next()
|
||||
if update_hidden_themes:
|
||||
hidden_themes = HiddenThemes.get_hidden_themes(viewings, token_id, token_secret)
|
||||
bar.next()
|
||||
if update_keyword_scores:
|
||||
keyword_scores = KeywordScores.get_keyword_scores(viewings)
|
||||
bar.next()
|
||||
if update_films_by_year:
|
||||
films_by_year = FilmsByYear.get_films_by_year(viewings)
|
||||
FilmsByYear.update_page(token_id, token_secret, films_by_year)
|
||||
if update_films_by_country:
|
||||
films_by_country = FilmsByCountry.get_films_by_country(viewings)
|
||||
FilmsByCountry.update_page(token_id, token_secret, films_by_country)
|
||||
if update_film_references:
|
||||
films_by_reference = FilmsByReference.get_films_by_reference(viewings)
|
||||
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)
|
||||
HiddenThemes.update_page(token_id, token_secret, hidden_themes)
|
||||
if update_keyword_scores:
|
||||
keyword_scores = KeywordScores.get_keyword_scores(viewings)
|
||||
KeywordScores.update_page(token_id, token_secret, keyword_scores)
|
||||
|
||||
bar.finish()
|
||||
|
||||
with IncrementalBar('Updating pages', max=update_page_count, check_tty=False) as bar:
|
||||
if update_films_by_year:
|
||||
FilmsByYear.update_page(token_id, token_secret, films_by_year)
|
||||
bar.next()
|
||||
if update_films_by_country:
|
||||
FilmsByCountry.update_page(token_id, token_secret, films_by_country)
|
||||
bar.next()
|
||||
if update_film_references:
|
||||
FilmsByReference.update_page(token_id, token_secret, films_by_reference)
|
||||
bar.next()
|
||||
if update_hidden_themes:
|
||||
HiddenThemes.update_page(token_id, token_secret, hidden_themes)
|
||||
bar.next()
|
||||
if update_keyword_scores:
|
||||
KeywordScores.update_page(token_id, token_secret, keyword_scores)
|
||||
bar.next()
|
||||
|
||||
bar.finish()
|
||||
print("Done!")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -80,9 +59,9 @@ if __name__ == '__main__':
|
|||
parser.add_argument('token_id', help='API token ID.')
|
||||
parser.add_argument('token_secret', help='API token secret.')
|
||||
|
||||
parser.add_argument('--update_csv', help='Update viewings.csv file, default: True', default=True, required=False)
|
||||
parser.add_argument("--do_not_update_csv", action="store_true")
|
||||
parser.add_argument('--pages', nargs="+", default=['years', 'countries', 'references', 'themes', 'scores'], required=False)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
update_wiki(args.token_id, args.token_secret, args.update_csv, args.pages)
|
||||
update_wiki(args.token_id, args.token_secret, not args.do_not_update_csv, args.pages)
|
||||
|
|
Loading…
Reference in New Issue