From 72e9234b2b030765df673282479342f5d7394f23 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 4 Jan 2023 08:24:18 +0700 Subject: [PATCH] fix playlist validator only validating active playlists --- .../home/src/download/yt_dlp_handler.py | 3 ++- tubearchivist/home/src/index/channel.py | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tubearchivist/home/src/download/yt_dlp_handler.py b/tubearchivist/home/src/download/yt_dlp_handler.py index 636f3fa5..7c8af776 100644 --- a/tubearchivist/home/src/download/yt_dlp_handler.py +++ b/tubearchivist/home/src/download/yt_dlp_handler.py @@ -104,7 +104,7 @@ class DownloadPostProcess: continue # validate from local - playlists = channel.get_indexed_playlists() + playlists = channel.get_indexed_playlists(active_only=True) all_channel_playlist = [i["playlist_id"] for i in playlists] self._validate_channel_playlist(all_channel_playlist, id_c) @@ -117,6 +117,7 @@ class DownloadPostProcess: playlist.build_json(scrape=True) if not playlist.json_data: playlist.deactivate() + continue playlist.add_vids_to_playlist() playlist.upload_to_es() diff --git a/tubearchivist/home/src/index/channel.py b/tubearchivist/home/src/index/channel.py index 90e0c116..894ce322 100644 --- a/tubearchivist/home/src/index/channel.py +++ b/tubearchivist/home/src/index/channel.py @@ -392,14 +392,16 @@ class YoutubeChannel(YouTubeItem): all_entries = [(i["id"], i["title"]) for i in playlists["entries"]] self.all_playlists = all_entries - def get_indexed_playlists(self): + def get_indexed_playlists(self, active_only=False): """get all indexed playlists from channel""" - data = { - "query": { - "term": {"playlist_channel_id": {"value": self.youtube_id}} - }, - "sort": [{"playlist_channel.keyword": {"order": "desc"}}], - } + must_list = [ + {"term": {"playlist_channel_id": {"value": self.youtube_id}}} + ] + if active_only: + must_list.append({"term": {"playlist_active": {"value": True}}}) + + data = {"query": {"bool": {"must": must_list}}} + all_playlists = IndexPaginate("ta_playlist", data).get_results() return all_playlists