switch ignore to API call

This commit is contained in:
simon 2022-12-22 19:42:59 +07:00
parent 7a9f5e5685
commit 8af10f8c07
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
3 changed files with 3 additions and 13 deletions

View File

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

View File

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

View File

@ -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();
}