feature/improve-references-page #10

Merged
sarah merged 10 commits from feature/improve-references-page into master 2022-12-09 21:17:42 +00:00
3 changed files with 34 additions and 4 deletions
Showing only changes of commit f36660d5bd - Show all commits

16
update_viewings_csv.py Normal file
View File

@ -0,0 +1,16 @@
import json
from wiki_pages import ViewingsCsv
def update_viewings_csv(token_id, token_secret):
print("Updating CSV")
ViewingsCsv.update_viewings_csv(token_id, token_secret)
print("Done!")
if __name__ == '__main__':
with open('token.json') as json_file:
token = json.load(json_file)
update_viewings_csv(token['token_id'], token['token_secret'])

View File

@ -121,10 +121,22 @@ def get_film_list(films):
film_links = [] film_links = []
for film in films: for film in films:
film_link = "[{}](https://www.imdb.com/title/tt{}/)".format(film['title'], film['imdb_id']) film_link = generate_imdb_film_link(film)
film_links.append(film_link) film_links.append(film_link)
if len(film_links) > 0: if len(film_links) > 0:
return "<br>".join(film_links) return "<br>".join(film_links)
else: else:
return "" return ""
def generate_markdown_link(text, url):
return "[{}]({})".format(text, url)
def generate_imdb_film_link(film):
return generate_markdown_link(film['title'], "https://www.imdb.com/title/tt{}/".format(film['imdb_id']))
def generate_wikipedia_page_link(page_title):
return generate_markdown_link(page_title, "https://en.wikipedia.org/wiki/{}".format(page_title.replace(" ", "_")))

View File

@ -2,7 +2,7 @@ import base64
from collections import Counter, OrderedDict from collections import Counter, OrderedDict
import csv import csv
import os import os
from wand.image import Image import pyvips
import worldmap import worldmap
import warnings import warnings
@ -94,8 +94,10 @@ def draw_map(films_by_country, file_name="vcinema_map.svg"):
worldmap.plot(countries, cmap=["#FF4000"], opacity=opacity, filename=file_name, verbose=False) worldmap.plot(countries, cmap=["#FF4000"], opacity=opacity, filename=file_name, verbose=False)
with Image(filename=file_name, width=1000, height=655) as i: image = pyvips.Image.new_from_file(file_name)
png_data = i.make_blob("png") image = image.thumbnail_image(1000, crop=pyvips.Interesting.ALL)
png_data = image.write_to_buffer(".png")
os.remove(file_name) os.remove(file_name)