From baacd3ee39cd9113f52532a23acf67d4a94e4145 Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 23 Oct 2022 12:21:27 +0700 Subject: [PATCH] better message for running and indexing queue --- tubearchivist/home/src/download/yt_dlp_handler.py | 15 ++++++++++++++- tubearchivist/home/src/ta/ta_redis.py | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tubearchivist/home/src/download/yt_dlp_handler.py b/tubearchivist/home/src/download/yt_dlp_handler.py index 52b0b733..4dcfe02d 100644 --- a/tubearchivist/home/src/download/yt_dlp_handler.py +++ b/tubearchivist/home/src/download/yt_dlp_handler.py @@ -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) diff --git a/tubearchivist/home/src/ta/ta_redis.py b/tubearchivist/home/src/ta/ta_redis.py index c684de7c..536209f5 100644 --- a/tubearchivist/home/src/ta/ta_redis.py +++ b/tubearchivist/home/src/ta/ta_redis.py @@ -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)