create gif
This commit is contained in:
parent
79ff5c76ec
commit
49bdcd0847
@ -5,6 +5,7 @@ import argparse
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from progress.bar import IncrementalBar
|
from progress.bar import IncrementalBar
|
||||||
|
|
||||||
|
import imageio
|
||||||
|
|
||||||
def generate_map_timelapse(token_id, token_secret):
|
def generate_map_timelapse(token_id, token_secret):
|
||||||
print("Getting viewings")
|
print("Getting viewings")
|
||||||
@ -19,18 +20,25 @@ def generate_map_timelapse(token_id, token_secret):
|
|||||||
date_viewings = OrderedDict(sorted(date_viewings.items(), key=lambda t: t[0]))
|
date_viewings = OrderedDict(sorted(date_viewings.items(), key=lambda t: t[0]))
|
||||||
|
|
||||||
running_country_counts = {}
|
running_country_counts = {}
|
||||||
|
print(len(date_viewings.keys()))
|
||||||
|
|
||||||
for date, viewings in date_viewings.items():
|
with imageio.get_writer('test.gif', mode='I', duration=0.1) as writer:
|
||||||
date_viewings_countries = VCinemaUtils.filter_viewings(viewings, "countries")
|
for date, viewings in date_viewings.items():
|
||||||
|
date_viewings_countries = VCinemaUtils.filter_viewings(viewings, "countries")
|
||||||
|
|
||||||
for country in date_viewings_countries:
|
for country in date_viewings_countries:
|
||||||
if country in running_country_counts.keys():
|
if country in running_country_counts.keys():
|
||||||
running_country_counts[country] += date_viewings_countries[country]
|
running_country_counts[country] += date_viewings_countries[country]
|
||||||
else:
|
else:
|
||||||
running_country_counts[country] = date_viewings_countries[country]
|
running_country_counts[country] = date_viewings_countries[country]
|
||||||
|
|
||||||
with open("map-{}.png".format(date), "wb") as f:
|
with open("map-{}.png".format(date), "wb") as f:
|
||||||
f.write(FilmsByCountry.draw_map(running_country_counts, file_name="map-{}.svg".format(date)))
|
f.write(FilmsByCountry.draw_map(running_country_counts, file_name="map-{}.svg".format(date)))
|
||||||
|
|
||||||
|
image = imageio.imread("map-{}.png".format(date))
|
||||||
|
writer.append_data(image)
|
||||||
|
|
||||||
|
print("done")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user