implement delete and ignore for video, #286
This commit is contained in:
parent
25edff28e7
commit
852abf254d
|
@ -592,7 +592,7 @@ class DownloadApiView(ApiBaseView):
|
|||
"""
|
||||
|
||||
search_base = "ta_download/_doc/"
|
||||
valid_status = ["pending", "ignore", "priority"]
|
||||
valid_status = ["pending", "ignore", "ignore-force", "priority"]
|
||||
permission_classes = [AdminOnly]
|
||||
|
||||
def get(self, request, video_id):
|
||||
|
@ -609,6 +609,11 @@ class DownloadApiView(ApiBaseView):
|
|||
print(message)
|
||||
return Response({"message": message}, status=400)
|
||||
|
||||
if item_status == "ignore-force":
|
||||
extrac_dl.delay(video_id, status="ignore")
|
||||
message = f"{video_id}: set status to ignore"
|
||||
return Response(request.data)
|
||||
|
||||
_, status_code = PendingInteract(video_id).get_item()
|
||||
if status_code == 404:
|
||||
message = f"{video_id}: item not found {status_code}"
|
||||
|
|
|
@ -214,7 +214,7 @@ def download_pending(self, auto_only=False):
|
|||
|
||||
|
||||
@shared_task(name="extract_download", bind=True, base=BaseTask)
|
||||
def extrac_dl(self, youtube_ids, auto_start=False):
|
||||
def extrac_dl(self, youtube_ids, auto_start=False, status="pending"):
|
||||
"""parse list passed and add to pending"""
|
||||
TaskManager().init(self)
|
||||
if isinstance(youtube_ids, str):
|
||||
|
@ -224,7 +224,7 @@ def extrac_dl(self, youtube_ids, auto_start=False):
|
|||
|
||||
pending_handler = PendingList(youtube_ids=to_add, task=self)
|
||||
pending_handler.parse_url_list()
|
||||
pending_handler.add_to_pending(auto_start=auto_start)
|
||||
pending_handler.add_to_pending(status=status, auto_start=auto_start)
|
||||
|
||||
if auto_start:
|
||||
download_pending.delay(auto_only=True)
|
||||
|
|
|
@ -92,7 +92,10 @@
|
|||
{% if request.user|has_group:"admin" or request.user.is_staff %}
|
||||
<button onclick="deleteConfirm()" id="delete-item">Delete Video</button>
|
||||
<div class="delete-confirm" id="delete-button">
|
||||
<span>Are you sure? </span><button class="danger-button" onclick="deleteVideo(this)" data-id="{{ video.youtube_id }}" data-redirect = "{{ video.channel.channel_id }}">Delete</button> <button onclick="cancelDelete()">Cancel</button>
|
||||
<span>Are you sure? </span>
|
||||
<button class="danger-button" onclick="deleteVideo(this)" data-id="{{ video.youtube_id }}" data-redirect = "{{ video.channel.channel_id }}">Delete</button>
|
||||
<button class="danger-button" onclick="deleteVideo(this)" data-id="{{ video.youtube_id }}" data-ignore data-redirect = "{{ video.channel.channel_id }}">Delete and ignore</button>
|
||||
<button onclick="cancelDelete()">Cancel</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
<button id="{{ video.youtube_id }}-button" data-id="{{ video.youtube_id }}" data-context="video" onclick="showAddToPlaylistMenu(this)">Add To Playlist</button>
|
||||
|
|
|
@ -503,9 +503,16 @@ function deleteConfirm() {
|
|||
|
||||
function deleteVideo(button) {
|
||||
let to_delete = button.getAttribute('data-id');
|
||||
let to_ignore = button.getAttribute('data-ignore');
|
||||
let to_redirect = button.getAttribute('data-redirect');
|
||||
let apiEndpoint = '/api/video/' + to_delete + '/';
|
||||
apiRequest(apiEndpoint, 'DELETE');
|
||||
let apiDeleteEndpoint = '/api/video/' + to_delete + '/';
|
||||
apiRequest(apiDeleteEndpoint, 'DELETE');
|
||||
|
||||
if (to_ignore !== null) {
|
||||
let apiIgnoreEndpoint = '/api/download/' + to_delete + '/';
|
||||
apiRequest(apiIgnoreEndpoint, 'POST', { status: 'ignore-force' });
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
let redirect = '/channel/' + to_redirect;
|
||||
window.location.replace(redirect);
|
||||
|
|
Loading…
Reference in New Issue