Compare commits

..

12 Commits

Author SHA1 Message Date
Sarah
f36660d5bd Merge branch 'master' into feature/improve-references-page 2022-12-04 14:13:31 +00:00
e47d22aa22 Merge pull request 'add helper functions' (#9) from simplify-markdown-link-create into master
Reviewed-on: #9
2022-12-04 14:12:07 +00:00
Sarah
d65dc51beb add helper functions 2022-12-04 14:11:27 +00:00
11ba1e6212 Merge pull request 'bugfix/map-has-no-border' (#8) from bugfix/map-has-no-border into master
Reviewed-on: #8
2022-09-09 21:44:24 +00:00
0bfcfeb701 Merge branch 'master' into bugfix/map-has-no-border 2022-09-09 21:44:11 +00:00
Sarah
417f81d6a5 remove comment 2022-09-09 22:43:18 +01:00
Sarah
00a50f7ce5 refactor 2022-09-09 22:42:52 +01:00
Sarah
ead6655b7b Delete get_file.py 2022-09-09 21:44:10 +01:00
Sarah
573c1cd990 make some changes 2022-09-09 21:42:53 +01:00
Sarah
1f13c2e878 Create update_viewings_csv.py 2022-09-09 21:31:55 +01:00
Sarah
ed07915a4d add changes - DOESNT WORK 2022-09-09 21:31:40 +01:00
Sarah
da3b95065b add test script 2022-09-09 21:31:26 +01:00
3 changed files with 34 additions and 4 deletions

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 = []
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)
if len(film_links) > 0:
return "<br>".join(film_links)
else:
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
import csv
import os
from wand.image import Image
import pyvips
import worldmap
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)
with Image(filename=file_name, width=1000, height=655) as i:
png_data = i.make_blob("png")
image = pyvips.Image.new_from_file(file_name)
image = image.thumbnail_image(1000, crop=pyvips.Interesting.ALL)
png_data = image.write_to_buffer(".png")
os.remove(file_name)