From c3bedc484493bcc3b071b29b515666692451f735 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Mon, 27 Nov 2023 02:06:48 -0800 Subject: fix: regression with youtube generation - fixed missing group and videoCount keys --- backend/fileutil.py | 2 +- backend/webapi/youtube.py | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/backend/fileutil.py b/backend/fileutil.py index 2aa2d6f..c12ae43 100644 --- a/backend/fileutil.py +++ b/backend/fileutil.py @@ -55,7 +55,7 @@ def get_local_channels(path: str = "data"): raise Exception("Local channel data not found") with open(path, "r", encoding="utf-8") as file: rows = file.read().splitlines() - return [tuple(row.split(",")) for row in rows] + return [tuple(row.split(":")) for row in rows] def check_diff_refresh(): diff --git a/backend/webapi/youtube.py b/backend/webapi/youtube.py index 44d786f..a25f5ba 100644 --- a/backend/webapi/youtube.py +++ b/backend/webapi/youtube.py @@ -37,16 +37,22 @@ class YouTubeAPI(WebAPI): snippet_list = snippet['items'] for i in range(len(stats_list)): try: + # group/sub_org is used to further divide channels into subsets (sorta like teams) + # can't think of a better match via YouTube API rn other than customUrl data_entry = {'english_name': channel_names[i], 'id': channel_ids[i], 'subscriber_count': - self._search_matching_id(channel_ids[i], stats_list)[ - 'statistics']['subscriberCount'], 'view_count': - self._search_matching_id(channel_ids[i], stats_list)[ - 'statistics']['viewCount'], 'photo': - self._search_matching_id(channel_ids[i], snippet_list)[ - 'snippet']['thumbnails']['default']['url'], 'description': - self._search_matching_id(channel_ids[i], snippet_list)[ - 'snippet']['description']} + self._search_matching_id(channel_ids[i], stats_list)['statistics']['subscriberCount'], + 'view_count': + self._search_matching_id(channel_ids[i], stats_list)['statistics']['viewCount'], + 'photo': + self._search_matching_id(channel_ids[i], snippet_list)['snippet']['thumbnails']['default']['url'], + 'description': + self._search_matching_id(channel_ids[i], snippet_list)['snippet']['description'], + 'group': + self._search_matching_id(channel_ids[i], snippet_list)['snippet']['customUrl'], + 'video_count': + self._search_matching_id(channel_ids[i], stats_list)['statistics']['videoCount'] + } data.append(data_entry) except TypeError: print("Error NoneType: " + str(channel_ids[i])) -- cgit v1.2.3