generate maps by running total

This commit is contained in:
Sarah 2022-04-22 22:13:21 +01:00
parent 1e970b4fb5
commit 79ff5c76ec

View File

@ -2,6 +2,7 @@ from wiki_pages import FilmsByCountry
from vcinema_utils import VCinemaUtils
import argparse
from collections import OrderedDict
from progress.bar import IncrementalBar
@ -15,13 +16,21 @@ def generate_map_timelapse(token_id, token_secret):
date_viewings = VCinemaUtils.filter_viewings(viewings, "date_watched")
date_viewings = OrderedDict(sorted(date_viewings.items(), key=lambda t: t[0]))
running_country_counts = {}
for date, viewings in date_viewings.items():
date_viewings_countries = VCinemaUtils.filter_viewings(viewings, "countries")
print(date_viewings_countries)
for country in date_viewings_countries:
if country in running_country_counts.keys():
running_country_counts[country] += date_viewings_countries[country]
else:
running_country_counts[country] = date_viewings_countries[country]
with open("map-{}.png".format(date), "wb") as f:
f.write(FilmsByCountry.draw_map(date_viewings_countries, file_name="map-{}.svg".format(date)))
f.write(FilmsByCountry.draw_map(running_country_counts, file_name="map-{}.svg".format(date)))
if __name__ == '__main__':