clean up playlist subscribe notification

This commit is contained in:
simon 2021-12-05 22:35:46 +07:00
parent 7516090e14
commit 82a71ed75d
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 10 additions and 12 deletions

View File

@ -401,25 +401,24 @@ class PlaylistSubscription:
all_youtube_ids = [i["youtube_id"] for i in all_indexed] all_youtube_ids = [i["youtube_id"] for i in all_indexed]
new_thumbs = [] new_thumbs = []
counter = 1 for idx, playlist in enumerate(new_playlists):
for playlist in new_playlists:
url_type = playlist["type"] url_type = playlist["type"]
playlist_id = playlist["url"] playlist_id = playlist["url"]
if not url_type == "playlist": if not url_type == "playlist":
print(f"{playlist_id} not a playlist, skipping...") print(f"{playlist_id} not a playlist, skipping...")
continue continue
playlisr = YoutubePlaylist( playlist_h = YoutubePlaylist(
playlist_id, all_youtube_ids=all_youtube_ids playlist_id, all_youtube_ids=all_youtube_ids
) )
if not playlisr.get_es_playlist(): if not playlist_h.get_es_playlist():
playlisr.get_playlist_dict() playlist_h.get_playlist_dict()
playlisr.playlist_dict["playlist_subscribed"] = subscribed playlist_h.playlist_dict["playlist_subscribed"] = subscribed
playlisr.upload_to_es() playlist_h.upload_to_es()
playlisr.add_vids_to_playlist() playlist_h.add_vids_to_playlist()
thumb = playlisr.playlist_dict["playlist_thumbnail"] thumb = playlist_h.playlist_dict["playlist_thumbnail"]
new_thumbs.append((playlist_id, thumb)) new_thumbs.append((playlist_id, thumb))
self.channel_validate(playlisr) self.channel_validate(playlist_h)
else: else:
self.change_subscribe(playlist_id, subscribe_status=True) self.change_subscribe(playlist_id, subscribe_status=True)
@ -428,12 +427,11 @@ class PlaylistSubscription:
"status": "message:subplaylist", "status": "message:subplaylist",
"level": "info", "level": "info",
"title": "Subscribing to Playlists", "title": "Subscribing to Playlists",
"message": f"Processing {counter} of {len(new_playlists)}", "message": f"Processing {idx + 1} of {len(new_playlists)}",
} }
RedisArchivist().set_message( RedisArchivist().set_message(
"message:subplaylist", message=message "message:subplaylist", message=message
) )
counter = counter + 1
return new_thumbs return new_thumbs