diff options
| author | Pinapelz <yukais@pinapelz.com> | 2023-11-27 02:06:48 -0800 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2023-11-27 02:06:48 -0800 |
| commit | c3bedc484493bcc3b071b29b515666692451f735 (patch) | |
| tree | 2f70552c0b0259d9487bbebadc13c20350d09b99 | |
| parent | 49e45901dee25402e1e093989848e8ab469f0038 (diff) | |
fix: regression with youtube generation
- fixed missing group and videoCount keys
| -rw-r--r-- | backend/fileutil.py | 2 | ||||
| -rw-r--r-- | 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])) |
