better message for running and indexing queue

This commit is contained in:
simon 2022-10-23 12:21:27 +07:00
parent 9cd23c3666
commit baacd3ee39
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 19 additions and 1 deletions

View File

@ -175,6 +175,14 @@ class VideoDownloader:
if not success:
continue
mess_dict = {
"status": self.MSG,
"level": "info",
"title": "Indexing....",
"message": "Add video metadata to index.",
}
RedisArchivist().set_message(self.MSG, mess_dict, expire=60)
vid_dict = index_new_video(
youtube_id, video_overwrites=self.video_overwrites
)
@ -187,12 +195,17 @@ class VideoDownloader:
}
RedisArchivist().set_message(self.MSG, mess_dict)
if queue.has_item():
message = "Continue with next video."
else:
message = "Download queue is finished."
self.move_to_archive(vid_dict)
mess_dict = {
"status": self.MSG,
"level": "info",
"title": "Completed",
"message": "",
"message": message,
}
RedisArchivist().set_message(self.MSG, mess_dict, expire=10)
self._delete_from_pending(youtube_id)

View File

@ -143,3 +143,8 @@ class RedisQueue(RedisBase):
def trim(self, size):
"""trim the queue based on settings amount"""
self.conn.execute_command("LTRIM", self.key, 0, size)
def has_item(self):
"""check if queue as at least one pending item"""
result = self.conn.execute_command("LRANGE", self.key, 0, 0)
return bool(result)