From 8af10f8c071723f0a5390a14a1406bf67f987a9e Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 22 Dec 2022 19:42:59 +0700 Subject: [PATCH] switch ignore to API call --- tubearchivist/api/views.py | 2 +- tubearchivist/home/src/frontend/api_calls.py | 10 ---------- tubearchivist/static/script.js | 4 ++-- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/tubearchivist/api/views.py b/tubearchivist/api/views.py index 51cf296..e24c2ef 100644 --- a/tubearchivist/api/views.py +++ b/tubearchivist/api/views.py @@ -404,7 +404,7 @@ class DownloadApiView(ApiBaseView): def post(self, request, video_id): """post to video to change status""" - item_status = request.data["status"] + item_status = request.data.get("status") if item_status not in self.valid_status: message = f"{video_id}: invalid status {item_status}" print(message) diff --git a/tubearchivist/home/src/frontend/api_calls.py b/tubearchivist/home/src/frontend/api_calls.py index 71c5182..47d68b3 100644 --- a/tubearchivist/home/src/frontend/api_calls.py +++ b/tubearchivist/home/src/frontend/api_calls.py @@ -53,7 +53,6 @@ class PostData: "change_view": self._change_view, "change_grid": self._change_grid, "rescan_pending": self._rescan_pending, - "ignore": self._ignore, "dl_pending": self._dl_pending, "queue": self._queue_handler, "unsubscribe": self._unsubscribe, @@ -112,15 +111,6 @@ class PostData: update_subscribed.delay() return {"success": True} - def _ignore(self): - """ignore from download queue""" - video_id = self.exec_val - print(f"{video_id}: ignore video from download queue") - PendingInteract(video_id=video_id, status="ignore").update_status() - # also clear from redis queue - RedisQueue(queue_name="dl_queue").clear_item(video_id) - return {"success": True} - @staticmethod def _dl_pending(): """start the download queue""" diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index 6b919bf..edf3de4 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -186,8 +186,8 @@ function dlPending() { function toIgnore(button) { let youtube_id = button.getAttribute('data-id'); - let payload = JSON.stringify({ ignore: youtube_id }); - sendPost(payload); + let apiEndpoint = '/api/download/' + youtube_id + '/'; + apiRequest(apiEndpoint, 'POST', {status: 'ignore'}); document.getElementById('dl-' + youtube_id).remove(); }