diff --git a/wiki_pages/HiddenThemes.py b/wiki_pages/HiddenThemes.py index 06bf3c9..6a8fb0c 100644 --- a/wiki_pages/HiddenThemes.py +++ b/wiki_pages/HiddenThemes.py @@ -28,28 +28,27 @@ def get_hidden_themes(viewings, token_id, token_secret): # Add hidden themes for date, data in viewings_filtered_watch_date.items(): - keyword_counts = {} + hidden_themes = set() if len(data['viewings']) > 1: + viewings_keywords = [] + for viewing in data['viewings']: if 'keywords' in viewing: - for keyword in viewing['keywords']: - if keyword in keyword_counts.keys(): - keyword_counts[keyword] += 1 - else: - keyword_counts[keyword] = 1 + viewings_keywords.append(set(viewing['keywords'])) - keyword_counts = {k: v for k, v in sorted(keyword_counts.items(), key=lambda item: item[1], reverse=True)} + if len(viewings_keywords) > 1: + hidden_themes = set.intersection(*viewings_keywords) - viewings_filtered_watch_date[date]['keyword_counts'] = keyword_counts + if hidden_themes != set(): + viewings_filtered_watch_date[date]['hidden_themes'] = list(hidden_themes) return viewings_filtered_watch_date def update_page(token_id, token_secret, hidden_themes): page = build_page(hidden_themes) - print(page) - # Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, PAGE_ID, markdown=page) + Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, PAGE_ID, markdown=page) def build_page(hidden_themes):