Fixed bug where videos are checked multiple times during synchronization. Fixed some errors when manually managing videos.

This commit is contained in:
Tiberiu Chibici 2019-08-19 13:47:36 +03:00
parent 2ae41efb9e
commit d1c3700c02
2 changed files with 8 additions and 9 deletions

View File

@ -69,7 +69,7 @@ class SynchronizeJob(Job):
batch_ids = [video.video_id for video in batch]
video_stats = {v.id: v for v in self.__api.videos(batch_ids, part='id,statistics')}
for video in itertools.chain(work_vids, self.__new_vids):
for video in batch:
self.progress_advance(1, "Updating video " + video.name)
self.check_video_deleted(video)
self.fetch_missing_thumbnails(video)

View File

@ -228,27 +228,27 @@ class Video(models.Model):
for file in self.get_files():
mime, _ = mimetypes.guess_type(file)
if mime is not None and mime.startswith('video/'):
return (file, mime)
return file, mime
return None, None
def delete_files(self):
if self.downloaded_path is not None:
from YtManagerApp.management.jobs.delete_video import schedule_delete_video
from YtManagerApp.management.jobs.delete_video import DeleteVideoJob
from YtManagerApp.management.appconfig import appconfig
from YtManagerApp.management.jobs.synchronize import schedule_synchronize_now_subscription
from YtManagerApp.management.jobs.synchronize import SynchronizeJob
schedule_delete_video(self)
DeleteVideoJob.schedule(self)
# Mark watched?
if self.subscription.user.preferences['mark_deleted_as_watched']:
self.watched = True
schedule_synchronize_now_subscription(self.subscription)
SynchronizeJob.schedule_now_for_subscription(self.subscription)
def download(self):
if not self.downloaded_path:
from YtManagerApp.management.jobs.download_video import schedule_download_video
schedule_download_video(self)
from YtManagerApp.management.jobs.download_video import DownloadVideoJob
DownloadVideoJob.schedule(self)
def __str__(self):
return self.name
@ -298,4 +298,3 @@ class JobMessage(models.Model):
message = models.CharField(max_length=1024, null=False, default="")
level = models.IntegerField(choices=JOB_MESSAGE_LEVELS, null=False, default=0)
suppress_notification = models.BooleanField(null=False, default=False)