From fcddf85245bf5175bed58a949cfad1e9e46178bd Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 18 Nov 2021 22:35:08 +0700 Subject: [PATCH] validate_playlists after run_queue from VideoDownloader --- tubearchivist/home/src/download.py | 15 +++++++++++++++ tubearchivist/home/tasks.py | 1 + 2 files changed, 16 insertions(+) diff --git a/tubearchivist/home/src/download.py b/tubearchivist/home/src/download.py index 8674428..eec24c6 100644 --- a/tubearchivist/home/src/download.py +++ b/tubearchivist/home/src/download.py @@ -637,3 +637,18 @@ class VideoDownloader: response = requests.delete(url, auth=es_auth) if not response.ok and not response.status_code == 404: print(response.text) + + def validate_playlists(self): + """update playlists""" + print("sync playlists") + all_indexed = PendingList().get_all_indexed() + all_youtube_ids = [i["youtube_id"] for i in all_indexed] + for channel_id in self.channels: + playlists = YoutubeChannel(channel_id).get_indexed_playlists() + all_playlist_ids = [i["playlist_id"] for i in playlists] + for playlist_id in all_playlist_ids: + playlist_handler = YoutubePlaylist( + playlist_id, all_youtube_ids=all_youtube_ids + ) + _ = playlist_handler.update_playlist() + playlist_handler.add_vids_to_playlist() diff --git a/tubearchivist/home/tasks.py b/tubearchivist/home/tasks.py index 2f49778..d081d84 100644 --- a/tubearchivist/home/tasks.py +++ b/tubearchivist/home/tasks.py @@ -71,6 +71,7 @@ def download_pending(): downloader = VideoDownloader() downloader.add_pending() downloader.run_queue() + downloader.validate_playlists() else: print("Did not acquire download lock.")