add limit_queue setting back, make buttons only show up while downlaoding

This commit is contained in:
simon 2021-09-24 21:27:53 +07:00
parent d0b54f8a88
commit f53391c1bb
3 changed files with 12 additions and 1 deletions

View File

@ -418,6 +418,10 @@ class VideoDownloader:
"""setup download queue in redis loop until no more items""" """setup download queue in redis loop until no more items"""
queue = RedisQueue("dl_queue") queue = RedisQueue("dl_queue")
limit_queue = self.config["downloads"]["limit_count"]
if limit_queue:
queue.trim(limit_queue - 1)
while True: while True:
youtube_id = queue.get_next() youtube_id = queue.get_next()
if not youtube_id: if not youtube_id:

View File

@ -166,6 +166,10 @@ class RedisQueue:
"""remove single item from list if it's there""" """remove single item from list if it's there"""
self.conn.execute_command("LREM", self.key, 0, to_clear) 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: class DurationConverter:
""" """

View File

@ -15,10 +15,13 @@ function checkMessage() {
req.open('GET', '/downloads/progress', true); req.open('GET', '/downloads/progress', true);
req.onload = function() { req.onload = function() {
var dlProgress = req.response; var dlProgress = req.response;
var dlStatus = dlProgress['status'];
if (dlProgress['status']) { if (dlProgress['status']) {
buildDownloadMessage(dlProgress); buildDownloadMessage(dlProgress);
handleInterval(); handleInterval();
buildDownloadIcons(); if (dlStatus == 'downloading') {
buildDownloadIcons();
};
}; };
}; };
req.send(); req.send();