from wiki_pages import FilmsByCountry from vcinema_utils import VCinemaUtils import argparse from progress.bar import IncrementalBar def generate_map_timelapse(token_id, token_secret): print("Getting viewings") viewings = VCinemaUtils.get_vcinema_viewings(token_id, token_secret, combine_repeat_viewings=False) 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, ['countries'], bar) date_viewings = VCinemaUtils.filter_viewings(viewings, "date_watched") for date, viewings in date_viewings.items(): date_viewings_countries = VCinemaUtils.filter_viewings(viewings, "countries") print(date_viewings_countries) with open("map-{}.png".format(date), "wb") as f: f.write(FilmsByCountry.draw_map(date_viewings_countries, file_name="map-{}.svg".format(date))) if __name__ == '__main__': parser = argparse.ArgumentParser(description='Update wiki pages.') parser.add_argument('token_id', help='API token ID.') parser.add_argument('token_secret', help='API token secret.') args = parser.parse_args() generate_map_timelapse(args.token_id, args.token_secret)