From f53391c1bbc1d64c0a92f6f51a08426862de4a59 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 24 Sep 2021 21:27:53 +0700 Subject: [PATCH] add limit_queue setting back, make buttons only show up while downlaoding --- tubearchivist/home/src/download.py | 4 ++++ tubearchivist/home/src/helper.py | 4 ++++ tubearchivist/static/progress.js | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tubearchivist/home/src/download.py b/tubearchivist/home/src/download.py index f915e79..f8cb72a 100644 --- a/tubearchivist/home/src/download.py +++ b/tubearchivist/home/src/download.py @@ -418,6 +418,10 @@ class VideoDownloader: """setup download queue in redis loop until no more items""" queue = RedisQueue("dl_queue") + limit_queue = self.config["downloads"]["limit_count"] + if limit_queue: + queue.trim(limit_queue - 1) + while True: youtube_id = queue.get_next() if not youtube_id: diff --git a/tubearchivist/home/src/helper.py b/tubearchivist/home/src/helper.py index c341352..5ef1be8 100644 --- a/tubearchivist/home/src/helper.py +++ b/tubearchivist/home/src/helper.py @@ -166,6 +166,10 @@ class RedisQueue: """remove single item from list if it's there""" self.conn.execute_command("LREM", self.key, 0, to_clear) + def trim(self, size): + """trim the queue based on settings amount""" + self.conn.execute_command("LTRIM", self.key, 0, size) + class DurationConverter: """ diff --git a/tubearchivist/static/progress.js b/tubearchivist/static/progress.js index aa70168..da12385 100644 --- a/tubearchivist/static/progress.js +++ b/tubearchivist/static/progress.js @@ -15,10 +15,13 @@ function checkMessage() { req.open('GET', '/downloads/progress', true); req.onload = function() { var dlProgress = req.response; + var dlStatus = dlProgress['status']; if (dlProgress['status']) { buildDownloadMessage(dlProgress); handleInterval(); - buildDownloadIcons(); + if (dlStatus == 'downloading') { + buildDownloadIcons(); + }; }; }; req.send();