From 8f3b832069d12f1dfdc6a68fad81663b8bdb373f Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 29 Apr 2023 12:55:12 +0700 Subject: [PATCH] [API] add dl autostart query param --- tubearchivist/api/views.py | 3 ++- tubearchivist/home/tasks.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tubearchivist/api/views.py b/tubearchivist/api/views.py index 2e3f142..5b2bf7f 100644 --- a/tubearchivist/api/views.py +++ b/tubearchivist/api/views.py @@ -483,6 +483,7 @@ class DownloadApiListView(ApiBaseView): def post(request): """add list of videos to download queue""" data = request.data + auto_start = bool(request.GET.get("autostart")) try: to_add = data["data"] except KeyError: @@ -499,7 +500,7 @@ class DownloadApiListView(ApiBaseView): print(message) return Response({"message": message}, status=400) - extrac_dl.delay(youtube_ids) + extrac_dl.delay(youtube_ids, auto_start=auto_start) return Response(data) diff --git a/tubearchivist/home/tasks.py b/tubearchivist/home/tasks.py index 66a9c58..1251891 100644 --- a/tubearchivist/home/tasks.py +++ b/tubearchivist/home/tasks.py @@ -190,7 +190,7 @@ def download_pending(self, auto_only=False): return manager.init(self) - VideoDownloader(task=self).run_queue(auto_only) + VideoDownloader(task=self).run_queue(auto_only=auto_only) @shared_task(name="extract_download", bind=True, base=BaseTask) @@ -206,6 +206,9 @@ def extrac_dl(self, youtube_ids, auto_start=False): pending_handler.parse_url_list() pending_handler.add_to_pending(auto_start=auto_start) + if auto_start: + download_pending.delay(auto_only=True) + @shared_task(bind=True, name="check_reindex", base=BaseTask) def check_reindex(self, data=False, extract_videos=False):