[API] add dl autostart query param

This commit is contained in:
simon 2023-04-29 12:55:12 +07:00
parent 9b3d1fa1fd
commit 8f3b832069
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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):