def delete_videos(request): """ API endpoint for deleting videos. """ youtube_ids = simplejson.loads(request.raw_post_data or "{}").get("youtube_ids", []) for id in youtube_ids: # Delete the file on disk delete_downloaded_files(id) # Delete the file in the database VideoFile.objects.filter(youtube_id=id).delete() return JsonResponse({})
def delete_videos(request): youtube_ids = simplejson.loads(request.raw_post_data or "{}").get("youtube_ids", []) for id in youtube_ids: # Delete the file on disk delete_downloaded_files(id) # Delete the file in the database videofile = get_object_or_None(VideoFile, youtube_id=id) if videofile: videofile.cancel_download = True videofile.flagged_for_download = False videofile.flagged_for_subtitle_download = False videofile.save() # Refresh the cache invalidate_all_pages_related_to_video(video_id=id) return JsonResponse({})