2018-10-27 00:33:45 +00:00
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
|
from django.http import JsonResponse
|
|
|
|
from django.views.generic import View
|
|
|
|
|
|
|
|
from YtManagerApp.models import Video
|
2020-04-10 21:30:24 +00:00
|
|
|
from YtManagerApp.services import Services
|
2018-10-20 22:20:31 +00:00
|
|
|
|
|
|
|
|
2018-10-27 00:33:45 +00:00
|
|
|
class SyncNowView(LoginRequiredMixin, View):
|
2018-10-20 22:20:31 +00:00
|
|
|
def post(self, *args, **kwargs):
|
2020-04-10 21:30:24 +00:00
|
|
|
Services.subscriptionManager().synchronize_all()
|
2018-10-20 22:20:31 +00:00
|
|
|
return JsonResponse({
|
|
|
|
'success': True
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2018-10-27 00:33:45 +00:00
|
|
|
class DeleteVideoFilesView(LoginRequiredMixin, View):
|
2018-10-20 22:20:31 +00:00
|
|
|
def post(self, *args, **kwargs):
|
|
|
|
video = Video.objects.get(id=kwargs['pk'])
|
2018-10-20 22:37:51 +00:00
|
|
|
video.delete_files()
|
2018-10-20 22:20:31 +00:00
|
|
|
return JsonResponse({
|
|
|
|
'success': True
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2018-10-27 00:33:45 +00:00
|
|
|
class DownloadVideoFilesView(LoginRequiredMixin, View):
|
2018-10-20 22:20:31 +00:00
|
|
|
def post(self, *args, **kwargs):
|
|
|
|
video = Video.objects.get(id=kwargs['pk'])
|
2018-10-20 22:37:51 +00:00
|
|
|
video.download()
|
2018-10-20 22:20:31 +00:00
|
|
|
return JsonResponse({
|
|
|
|
'success': True
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2018-10-27 00:33:45 +00:00
|
|
|
class MarkVideoWatchedView(LoginRequiredMixin, View):
|
2018-10-20 22:20:31 +00:00
|
|
|
def post(self, *args, **kwargs):
|
|
|
|
video = Video.objects.get(id=kwargs['pk'])
|
2018-10-20 22:37:51 +00:00
|
|
|
video.mark_watched()
|
2018-10-20 22:20:31 +00:00
|
|
|
return JsonResponse({
|
|
|
|
'success': True
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2018-10-27 00:33:45 +00:00
|
|
|
class MarkVideoUnwatchedView(LoginRequiredMixin, View):
|
2018-10-20 22:20:31 +00:00
|
|
|
def post(self, *args, **kwargs):
|
|
|
|
video = Video.objects.get(id=kwargs['pk'])
|
2018-10-20 22:37:51 +00:00
|
|
|
video.mark_unwatched()
|
2018-10-20 22:20:31 +00:00
|
|
|
video.save()
|
|
|
|
return JsonResponse({
|
|
|
|
'success': True
|
|
|
|
})
|