use message:playlistscan for index_channel_playlists

This commit is contained in:
simon 2021-12-03 21:05:34 +07:00
parent b35440253d
commit f7b5082983
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -44,7 +44,7 @@ def update_subscribed():
"status": "message:rescan", "status": "message:rescan",
"level": "info", "level": "info",
"title": "Rescanning channels and playlists.", "title": "Rescanning channels and playlists.",
"message": "Looking for new videos." "message": "Looking for new videos.",
} }
RedisArchivist().set_message("message:rescan", message) RedisArchivist().set_message("message:rescan", message)
@ -259,6 +259,15 @@ def subscribe_to(url_str):
def index_channel_playlists(channel_id): def index_channel_playlists(channel_id):
"""add all playlists of channel to index""" """add all playlists of channel to index"""
channel_handler = YoutubeChannel(channel_id) channel_handler = YoutubeChannel(channel_id)
channel_name = channel_handler.channel_dict["channel_name"]
# notify
mess_dict = {
"status": "message:playlistscan",
"level": "info",
"title": "Looking for playlists",
"message": f'Scanning channel "{channel_name}" in progress',
}
RedisArchivist().set_message("message:playlistscan", mess_dict)
all_playlists = channel_handler.get_all_playlists() all_playlists = channel_handler.get_all_playlists()
if not all_playlists: if not all_playlists:
@ -268,7 +277,16 @@ def index_channel_playlists(channel_id):
all_indexed = PendingList().get_all_indexed() all_indexed = PendingList().get_all_indexed()
all_youtube_ids = [i["youtube_id"] for i in all_indexed] all_youtube_ids = [i["youtube_id"] for i in all_indexed]
counter = 1
for playlist_id, playlist_title in all_playlists: for playlist_id, playlist_title in all_playlists:
# notify
mess_dict = {
"status": "message:playlistscan",
"level": "info",
"title": "Scanning channel for playlists",
"message": f"Progress: {counter}/{len(all_playlists)}",
}
RedisArchivist().set_message("message:playlistscan", mess_dict)
print("add playlist: " + playlist_title) print("add playlist: " + playlist_title)
playlist_handler = YoutubePlaylist( playlist_handler = YoutubePlaylist(
playlist_id, all_youtube_ids=all_youtube_ids playlist_id, all_youtube_ids=all_youtube_ids
@ -287,6 +305,7 @@ def index_channel_playlists(channel_id):
continue continue
playlist_handler.upload_to_es() playlist_handler.upload_to_es()
playlist_handler.add_vids_to_playlist() playlist_handler.add_vids_to_playlist()
counter = counter + 1
if all_playlists: if all_playlists:
handler = ThumbManager() handler = ThumbManager()