From 1f82f0c40dc7e2f7e4114c77404a15b9a4939cb7 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 26 Nov 2021 17:34:59 +0700 Subject: [PATCH] index playlist channel if doesn't exist and beter user feedback --- tubearchivist/home/src/download.py | 33 +++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tubearchivist/home/src/download.py b/tubearchivist/home/src/download.py index f91b11c..742fed2 100644 --- a/tubearchivist/home/src/download.py +++ b/tubearchivist/home/src/download.py @@ -415,6 +415,7 @@ class PlaylistSubscription: playlist_handler.add_vids_to_playlist() thumb = playlist_handler.playlist_dict["playlist_thumbnail"] new_thumbs.append((playlist_id, thumb)) + self.channel_validate(playlist_handler) else: self.change_subscribe(playlist_id, subscribe_status=True) @@ -425,6 +426,16 @@ class PlaylistSubscription: return new_thumbs + @staticmethod + def channel_validate(playlist_handler): + """make sure channel of playlist is there""" + channel_id = playlist_handler.playlist_dict["playlist_channel_id"] + channel_handler = YoutubeChannel(channel_id) + if channel_handler.source == "scraped": + channel_handler.channel_dict["channel_subscribed"] = False + channel_handler.upload_to_es() + channel_handler.get_channel_art() + def change_subscribe(self, playlist_id, subscribe_status): """change the subscribe status of a playlist""" es_url = self.config["application"]["es_url"] @@ -533,6 +544,13 @@ class VideoDownloader: @staticmethod def add_pending(): """add pending videos to download queue""" + mess_dict = { + "status": "downloading", + "level": "info", + "title": "Looking for videos to download", + "message": "", + } + RedisArchivist().set_message("progress:download", mess_dict) all_pending, _ = PendingList().get_all_pending() to_add = [i["youtube_id"] for i in all_pending] if not to_add: @@ -690,9 +708,22 @@ class VideoDownloader: if not response.ok and not response.status_code == 404: print(response.text) + def add_subscribed_channels(self): + """add all channels subscribed to refresh""" + all_subscribed = PlaylistSubscription().get_playlists() + if not all_subscribed: + return + + channel_ids = [i["playlist_channel_id"] for i in all_subscribed] + for channel_id in channel_ids: + self.channels.add(channel_id) + + return + def validate_playlists(self): - """update playlists""" + """look for playlist needing to update""" print("sync playlists") + self.add_subscribed_channels() all_indexed = PendingList().get_all_indexed() all_youtube_ids = [i["youtube_id"] for i in all_indexed] c_counter = 1