From 5d0d050149ea8195d19dac6448789a32da5c77a3 Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 7 May 2023 17:45:48 +0700 Subject: [PATCH] fix channel reindex flow --- tubearchivist/home/src/index/channel.py | 4 ++-- tubearchivist/home/src/index/reindex.py | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tubearchivist/home/src/index/channel.py b/tubearchivist/home/src/index/channel.py index eef5cdb..7ceeccb 100644 --- a/tubearchivist/home/src/index/channel.py +++ b/tubearchivist/home/src/index/channel.py @@ -47,13 +47,13 @@ class YoutubeChannel(YouTubeItem): if not self.youtube_meta and fallback: self._video_fallback(fallback) else: - self._process_youtube_meta() + self.process_youtube_meta() self.get_channel_art() if upload: self.upload_to_es() - def _process_youtube_meta(self): + def process_youtube_meta(self): """extract relevant fields""" self.youtube_meta["thumbnails"].reverse() channel_subs = self.youtube_meta.get("channel_follower_count") or 0 diff --git a/tubearchivist/home/src/index/reindex.py b/tubearchivist/home/src/index/reindex.py index b5ae83c..7473c89 100644 --- a/tubearchivist/home/src/index/reindex.py +++ b/tubearchivist/home/src/index/reindex.py @@ -331,23 +331,29 @@ class Reindex(ReindexBase): @staticmethod def _reindex_single_channel(channel_id): """refresh channel data and sync to videos""" + # read current state channel = YoutubeChannel(channel_id) channel.get_from_es() - subscribed = channel.json_data["channel_subscribed"] - overwrites = channel.json_data.get("channel_overwrites", False) + es_meta = channel.json_data.copy() + + # get new channel.get_from_youtube() - if not channel.json_data: + if not channel.youtube_meta: channel.deactivate() channel.get_from_es() channel.sync_to_videos() return - channel.json_data["channel_subscribed"] = subscribed + channel.process_youtube_meta() + channel.get_channel_art() + + # add back + channel.json_data["channel_subscribed"] = es_meta["channel_subscribed"] + overwrites = es_meta.get("channel_overwrites") if overwrites: channel.json_data["channel_overwrites"] = overwrites - channel.upload_to_es() - channel.sync_to_videos() + channel.upload_to_es() ChannelFullScan(channel_id).scan() def _reindex_single_playlist(self, playlist_id):