mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 03:40:14 +00:00
API: sort and query filter download view, delete by filter
This commit is contained in:
parent
40bb3e880e
commit
d086f63861
@ -136,7 +136,10 @@ POST /api/channel/
|
|||||||
/api/playlist/\<playlist_id>/video/
|
/api/playlist/\<playlist_id>/video/
|
||||||
|
|
||||||
## Download Queue List View
|
## Download Queue List View
|
||||||
/api/download/
|
GET /api/download/
|
||||||
|
|
||||||
|
Parameter:
|
||||||
|
- filter: pending, ignore
|
||||||
|
|
||||||
### Add list of videos to download queue
|
### Add list of videos to download queue
|
||||||
POST /api/download/
|
POST /api/download/
|
||||||
@ -148,6 +151,10 @@ POST /api/download/
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Delete download queue items by filter
|
||||||
|
DELETE /api/download/?filter=ignore
|
||||||
|
DELETE /api/download/?filter=pending
|
||||||
|
|
||||||
## Download Queue Item View
|
## Download Queue Item View
|
||||||
GET /api/download/\<video_id>/
|
GET /api/download/\<video_id>/
|
||||||
POST /api/download/\<video_id>/
|
POST /api/download/\<video_id>/
|
||||||
|
@ -337,14 +337,28 @@ class DownloadApiListView(ApiBaseView):
|
|||||||
"""resolves to /api/download/
|
"""resolves to /api/download/
|
||||||
GET: returns latest videos in the download queue
|
GET: returns latest videos in the download queue
|
||||||
POST: add a list of videos to download queue
|
POST: add a list of videos to download queue
|
||||||
|
DELETE: remove items based on query filter
|
||||||
"""
|
"""
|
||||||
|
|
||||||
search_base = "ta_download/_search/"
|
search_base = "ta_download/_search/"
|
||||||
|
valid_filter = ["pending", "ignore"]
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
"""get request"""
|
"""get request"""
|
||||||
data = {"query": {"match_all": {}}}
|
query_filter = request.GET.get("filter", False)
|
||||||
|
data = {
|
||||||
|
"query": {"match_all": {}},
|
||||||
|
"sort": [{"timestamp": {"order": "asc"}}],
|
||||||
|
}
|
||||||
|
if query_filter:
|
||||||
|
if query_filter not in self.valid_filter:
|
||||||
|
message = f"invalid url query filder: {query_filter}"
|
||||||
|
print(message)
|
||||||
|
return Response({"message": message}, status=400)
|
||||||
|
|
||||||
|
data["query"] = {"term": {"status": {"value": query_filter}}}
|
||||||
|
|
||||||
self.get_document_list(data)
|
self.get_document_list(data)
|
||||||
self.get_paginate()
|
self.get_paginate()
|
||||||
return Response(self.response)
|
return Response(self.response)
|
||||||
@ -374,6 +388,20 @@ class DownloadApiListView(ApiBaseView):
|
|||||||
|
|
||||||
return Response(data)
|
return Response(data)
|
||||||
|
|
||||||
|
def delete(self, request):
|
||||||
|
"""delete download queue"""
|
||||||
|
query_filter = request.GET.get("filter", False)
|
||||||
|
if query_filter not in self.valid_filter:
|
||||||
|
message = f"invalid url query filter: {query_filter}"
|
||||||
|
print(message)
|
||||||
|
return Response({"message": message}, status=400)
|
||||||
|
|
||||||
|
message = f"delete queue by status: {query_filter}"
|
||||||
|
print(message)
|
||||||
|
PendingInteract(status=query_filter).delete_by_status()
|
||||||
|
|
||||||
|
return Response({"message": message})
|
||||||
|
|
||||||
|
|
||||||
class PingView(ApiBaseView):
|
class PingView(ApiBaseView):
|
||||||
"""resolves to /api/ping/
|
"""resolves to /api/ping/
|
||||||
|
Loading…
Reference in New Issue
Block a user