move update

This commit is contained in:
Sarah 2022-04-16 09:43:51 +01:00
parent 2c58075c6b
commit 63c37aa3b7
6 changed files with 35 additions and 11 deletions

View File

@ -1,4 +1,3 @@
from bookstack import Bookstack
from wiki_pages import FilmsByCountry, FilmsByReference, FilmsByYear, HiddenThemes, KeywordScores, ViewingsCsv
from vcinema_utils import VCinemaUtils
@ -53,24 +52,19 @@ def update_wiki(token_id, token_secret, update_csv, update_films_by_year, update
with IncrementalBar('Updating pages', max=update_page_count, check_tty=False) as bar:
if update_films_by_year:
films_by_year_page = FilmsByYear.build_page(films_by_year)
Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, FilmsByYear.PAGE_ID, markdown=films_by_year_page)
FilmsByYear.update_page(films_by_year)
bar.next()
if update_films_by_country:
films_by_country_page = FilmsByCountry.build_page(films_by_country)
Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, FilmsByCountry.PAGE_ID, markdown=films_by_country_page)
FilmsByCountry.update_page(films_by_country)
bar.next()
if update_film_references:
films_by_reference_page = FilmsByReference.build_page(films_by_reference)
Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, FilmsByReference.PAGE_ID, markdown=films_by_reference_page)
FilmsByReference.update_page(films_by_reference)
bar.next()
if update_hidden_themes:
hidden_themes_page = HiddenThemes.build_page(hidden_themes)
Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, HiddenThemes.PAGE_ID, markdown=hidden_themes_page)
HiddenThemes.update_page(hidden_themes)
bar.next()
if update_keyword_scores:
keyword_scores_page = KeywordScores.build_page(keyword_scores)
Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, KeywordScores.PAGE_ID, markdown=keyword_scores_page)
KeywordScores.update_page(keyword_scores)
bar.next()
bar.finish()

View File

@ -1,3 +1,4 @@
from bookstack import Bookstack
from vcinema_utils import VCinemaUtils
import base64
@ -23,6 +24,11 @@ def get_films_by_country(viewings):
return viewings_filtered_by_country
def update_page(token_id, token_secret, films_by_country):
page = build_page(films_by_country)
Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, PAGE_ID, markdown=page)
def build_page(films_by_country):
table = build_table(films_by_country)

View File

@ -1,6 +1,7 @@
from collections import OrderedDict
import string
from bookstack import Bookstack
from vcinema_utils import VCinemaUtils
# Page ID of https://wiki.jacknet.io/books/vcinema/page/references
@ -14,6 +15,11 @@ def get_films_by_reference(viewings):
return viewings_filtered_by_reference_keyword
def update_page(token_id, token_secret, films_by_reference_keyword):
page = build_page(films_by_reference_keyword)
Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, PAGE_ID, markdown=page)
def build_page(films_by_reference_keyword):
reference_keywords_sorted = OrderedDict(sorted(films_by_reference_keyword.items(), key=lambda t: t[0]))

View File

@ -1,5 +1,6 @@
from collections import OrderedDict
from bookstack import Bookstack
from vcinema_utils import VCinemaUtils
# Page ID of https://wiki.jacknet.io/books/vcinema/page/films-by-release-year
@ -12,6 +13,11 @@ def get_films_by_year(viewings):
return viewings_filtered_by_year
def update_page(token_id, token_secret, films_by_year):
page = build_page(films_by_year)
Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, PAGE_ID, markdown=page)
def build_page(films_by_year):
films_by_year_sorted = OrderedDict(sorted(films_by_year.items(), key=lambda t: t[0], reverse=True))

View File

@ -1,5 +1,6 @@
from collections import OrderedDict
from bookstack import Bookstack
from vcinema_utils import VCinemaUtils
# Page ID of https://wiki.jacknet.io/books/vcinema/page/films-by-reference
@ -45,6 +46,11 @@ def get_hidden_themes(viewings, token_id, token_secret):
return viewings_filtered_watch_date
def update_page(token_id, token_secret, hidden_themes):
page = build_page(hidden_themes)
Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, PAGE_ID, markdown=page)
def build_page(hidden_themes):
hidden_themes = OrderedDict(sorted(hidden_themes.items(), key=lambda t: t[0]))

View File

@ -3,6 +3,7 @@ from progress.bar import IncrementalBar
import math
from concurrent.futures import ThreadPoolExecutor
from bookstack import Bookstack
from imdb_utils import IMDbUtils
from vcinema_utils import VCinemaUtils
@ -25,6 +26,11 @@ def get_keyword_scores(viewings):
return viewings_filtered_keyword
def update_page(token_id, token_secret, keyword_data):
page = build_page(keyword_data)
Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, PAGE_ID, markdown=page)
def add_keyword_totals(keywords, min_vcinema_count):
keyword_count = len([keyword for keyword in keywords.keys() if len(keywords[keyword]['vcinema_films']) >= min_vcinema_count])