From 82a71ed75dccdd875aa08e91104b454275972488 Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 5 Dec 2021 22:35:46 +0700 Subject: [PATCH] clean up playlist subscribe notification --- tubearchivist/home/src/download.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/tubearchivist/home/src/download.py b/tubearchivist/home/src/download.py index e300d1e..fd2ffbb 100644 --- a/tubearchivist/home/src/download.py +++ b/tubearchivist/home/src/download.py @@ -401,25 +401,24 @@ class PlaylistSubscription: all_youtube_ids = [i["youtube_id"] for i in all_indexed] new_thumbs = [] - counter = 1 - for playlist in new_playlists: + for idx, playlist in enumerate(new_playlists): url_type = playlist["type"] playlist_id = playlist["url"] if not url_type == "playlist": print(f"{playlist_id} not a playlist, skipping...") continue - playlisr = YoutubePlaylist( + playlist_h = YoutubePlaylist( playlist_id, all_youtube_ids=all_youtube_ids ) - if not playlisr.get_es_playlist(): - playlisr.get_playlist_dict() - playlisr.playlist_dict["playlist_subscribed"] = subscribed - playlisr.upload_to_es() - playlisr.add_vids_to_playlist() - thumb = playlisr.playlist_dict["playlist_thumbnail"] + if not playlist_h.get_es_playlist(): + playlist_h.get_playlist_dict() + playlist_h.playlist_dict["playlist_subscribed"] = subscribed + playlist_h.upload_to_es() + playlist_h.add_vids_to_playlist() + thumb = playlist_h.playlist_dict["playlist_thumbnail"] new_thumbs.append((playlist_id, thumb)) - self.channel_validate(playlisr) + self.channel_validate(playlist_h) else: self.change_subscribe(playlist_id, subscribe_status=True) @@ -428,12 +427,11 @@ class PlaylistSubscription: "status": "message:subplaylist", "level": "info", "title": "Subscribing to Playlists", - "message": f"Processing {counter} of {len(new_playlists)}", + "message": f"Processing {idx + 1} of {len(new_playlists)}", } RedisArchivist().set_message( "message:subplaylist", message=message ) - counter = counter + 1 return new_thumbs