vcinema/roundup_scripts/get_new_years.py

41 lines
1.5 KiB
Python
Raw Permalink Normal View History

2022-12-16 21:15:41 +00:00
import argparse
from datetime import datetime
import json
from progress.bar import IncrementalBar
from vcinema_utils import VCinemaUtils
def get_new_years(token_id, token_secret, year):
print("Getting viewings")
viewings = VCinemaUtils.get_vcinema_viewings(token_id, token_secret)
with IncrementalBar('Retrieving movie data', max=len(viewings), suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
VCinemaUtils.add_imdb_data_to_viewings(viewings, ["year"], bar)
viewings_before_year = VCinemaUtils.get_viewings_before_date(viewings, datetime(day=31, month=12, year=year-1))
viewings_end_of_year = VCinemaUtils.get_viewings_before_date(viewings, datetime(day=31, month=12, year=year))
viewings_before_year_filtered_by_year = VCinemaUtils.filter_viewings(viewings_before_year, "year")
viewings_end_of_year_filtered_by_year = VCinemaUtils.filter_viewings(viewings_end_of_year, "year")
years_before = set(list(viewings_before_year_filtered_by_year.keys()))
years_after = set(list(viewings_end_of_year_filtered_by_year.keys()))
years_diff = years_after - years_before
print(years_diff)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Update wiki pages.')
parser.add_argument('year', type=int)
args = parser.parse_args()
with open('../token.json') as json_file:
token = json.load(json_file)
get_new_years(token['token_id'], token['token_secret'], args.year)