mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-02 09:41:07 +00:00
clean up progress hook title and speed up playlist validation
This commit is contained in:
parent
19871d55e2
commit
8874168291
@ -587,8 +587,10 @@ class VideoDownloader:
|
|||||||
def progress_hook(response):
|
def progress_hook(response):
|
||||||
"""process the progress_hooks from youtube_dl"""
|
"""process the progress_hooks from youtube_dl"""
|
||||||
# title
|
# title
|
||||||
filename = response["filename"][12:].replace("_", " ")
|
path = os.path.split(response["filename"])[-1][12:]
|
||||||
title = "Downloading: " + os.path.split(filename)[-1]
|
filename = os.path.splitext(os.path.splitext(path)[0])[0]
|
||||||
|
filename_clean = filename.replace("_", " ")
|
||||||
|
title = "Downloading: " + filename_clean
|
||||||
# message
|
# message
|
||||||
try:
|
try:
|
||||||
percent = response["_percent_str"]
|
percent = response["_percent_str"]
|
||||||
@ -597,7 +599,7 @@ class VideoDownloader:
|
|||||||
eta = response["_eta_str"]
|
eta = response["_eta_str"]
|
||||||
message = f"{percent} of {size} at {speed} - time left: {eta}"
|
message = f"{percent} of {size} at {speed} - time left: {eta}"
|
||||||
except KeyError:
|
except KeyError:
|
||||||
message = ""
|
message = "processing"
|
||||||
mess_dict = {
|
mess_dict = {
|
||||||
"status": "message:download",
|
"status": "message:download",
|
||||||
"level": "info",
|
"level": "info",
|
||||||
@ -741,12 +743,10 @@ class VideoDownloader:
|
|||||||
self.add_subscribed_channels()
|
self.add_subscribed_channels()
|
||||||
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]
|
||||||
c_counter = 1
|
for id_c, channel_id in enumerate(self.channels):
|
||||||
for channel_id in self.channels:
|
|
||||||
playlists = YoutubeChannel(channel_id).get_indexed_playlists()
|
playlists = YoutubeChannel(channel_id).get_indexed_playlists()
|
||||||
all_playlist_ids = [i["playlist_id"] for i in playlists]
|
all_playlist_ids = [i["playlist_id"] for i in playlists]
|
||||||
p_counter = 1
|
for id_p, playlist_id in enumerate(all_playlist_ids):
|
||||||
for playlist_id in all_playlist_ids:
|
|
||||||
playlist_handler = YoutubePlaylist(
|
playlist_handler = YoutubePlaylist(
|
||||||
playlist_id, all_youtube_ids=all_youtube_ids
|
playlist_id, all_youtube_ids=all_youtube_ids
|
||||||
)
|
)
|
||||||
@ -759,15 +759,18 @@ class VideoDownloader:
|
|||||||
# notify
|
# notify
|
||||||
title = (
|
title = (
|
||||||
"Processing playlists for channels: "
|
"Processing playlists for channels: "
|
||||||
+ f"{c_counter}/{len(self.channels)}"
|
+ f"{id_c + 1}/{len(self.channels)}"
|
||||||
)
|
)
|
||||||
message = f"Progress: {p_counter}/{len(all_playlist_ids)}"
|
message = f"Progress: {id_p + 1}/{len(all_playlist_ids)}"
|
||||||
mess_dict = {
|
mess_dict = {
|
||||||
"status": "message:download",
|
"status": "message:download",
|
||||||
"level": "info",
|
"level": "info",
|
||||||
"title": title,
|
"title": title,
|
||||||
"message": message,
|
"message": message,
|
||||||
}
|
}
|
||||||
RedisArchivist().set_message("message:download", mess_dict)
|
if id_p + 1 == len(all_playlist_ids):
|
||||||
p_counter = p_counter + 1
|
RedisArchivist().set_message(
|
||||||
c_counter = c_counter + 1
|
"message:download", mess_dict, expire=4
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
RedisArchivist().set_message("message:download", mess_dict)
|
||||||
|
Loading…
Reference in New Issue
Block a user