fix channel reindex flow

This commit is contained in:
simon 2023-05-07 17:45:48 +07:00
parent c327e94726
commit 5d0d050149
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 14 additions and 8 deletions

View File

@ -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

View File

@ -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):