Compare commits
12 Commits
95e7804a4a
...
f36660d5bd
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f36660d5bd | ||
e47d22aa22 | |||
![]() |
d65dc51beb | ||
11ba1e6212 | |||
0bfcfeb701 | |||
![]() |
417f81d6a5 | ||
![]() |
00a50f7ce5 | ||
![]() |
ead6655b7b | ||
![]() |
573c1cd990 | ||
![]() |
1f13c2e878 | ||
![]() |
ed07915a4d | ||
![]() |
da3b95065b |
16
update_viewings_csv.py
Normal file
16
update_viewings_csv.py
Normal 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'])
|
@ -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(" ", "_")))
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user