diff --git a/tubearchivist/api/views.py b/tubearchivist/api/views.py index f21292e8..3e5d79e8 100644 --- a/tubearchivist/api/views.py +++ b/tubearchivist/api/views.py @@ -382,7 +382,7 @@ class DownloadApiView(ApiBaseView): print(f"{video_id}: change status to {item_status}") PendingInteract(video_id=video_id, status=item_status).update_status() - RedisQueue().clear_item(video_id) + RedisQueue(queue_name="dl_queue").clear_item(video_id) return Response(request.data) diff --git a/tubearchivist/home/src/download/yt_dlp_handler.py b/tubearchivist/home/src/download/yt_dlp_handler.py index 3c6a4a56..c1d5ddde 100644 --- a/tubearchivist/home/src/download/yt_dlp_handler.py +++ b/tubearchivist/home/src/download/yt_dlp_handler.py @@ -184,7 +184,7 @@ class VideoDownloader: """setup download queue in redis loop until no more items""" self._setup_queue() - queue = RedisQueue() + queue = RedisQueue(queue_name="dl_queue") limit_queue = self.config["downloads"]["limit_count"] if limit_queue: @@ -275,7 +275,7 @@ class VideoDownloader: RedisArchivist().set_message(self.MSG, mess_dict, expire=True) return - RedisQueue().add_list(to_add) + RedisQueue(queue_name="dl_queue").add_list(to_add) def _progress_hook(self, response): """process the progress_hooks from yt_dlp""" diff --git a/tubearchivist/home/src/frontend/api_calls.py b/tubearchivist/home/src/frontend/api_calls.py index d8325fbe..6e0bb78d 100644 --- a/tubearchivist/home/src/frontend/api_calls.py +++ b/tubearchivist/home/src/frontend/api_calls.py @@ -123,7 +123,7 @@ class PostData: print(f"{video_id}: ignore video from download queue") PendingInteract(video_id=video_id, status="ignore").update_status() # also clear from redis queue - RedisQueue().clear_item(video_id) + RedisQueue(queue_name="dl_queue").clear_item(video_id) return {"success": True} @staticmethod @@ -141,7 +141,7 @@ class PostData: to_execute = self.exec_val if to_execute == "stop": print("stopping download queue") - RedisQueue().clear() + RedisQueue(queue_name="dl_queue").clear() elif to_execute == "kill": task_id = RedisArchivist().get_message("dl_queue_id") if not isinstance(task_id, str): diff --git a/tubearchivist/home/src/ta/ta_redis.py b/tubearchivist/home/src/ta/ta_redis.py index 536209f5..e963dfdd 100644 --- a/tubearchivist/home/src/ta/ta_redis.py +++ b/tubearchivist/home/src/ta/ta_redis.py @@ -102,11 +102,11 @@ class RedisArchivist(RedisBase): class RedisQueue(RedisBase): - """dynamically interact with the download queue in redis""" + """dynamically interact with queues in redis""" - def __init__(self): + def __init__(self, queue_name): super().__init__() - self.key = self.NAME_SPACE + "dl_queue" + self.key = f"{self.NAME_SPACE}{queue_name}" def get_all(self): """return all elements in list""" diff --git a/tubearchivist/home/tasks.py b/tubearchivist/home/tasks.py index b868da50..d7200510 100644 --- a/tubearchivist/home/tasks.py +++ b/tubearchivist/home/tasks.py @@ -99,7 +99,7 @@ def download_pending(): @shared_task def download_single(youtube_id): """start download single video now""" - queue = RedisQueue() + queue = RedisQueue(queue_name="dl_queue") queue.add_priority(youtube_id) print("Added to queue with priority: " + youtube_id) # start queue if needed @@ -192,7 +192,7 @@ def kill_dl(task_id): app.control.revoke(task_id, terminate=True) _ = RedisArchivist().del_message("dl_queue_id") - RedisQueue().clear() + RedisQueue(queue_name="dl_queue").clear() clear_dl_cache(CONFIG)