From d1c3700c0229df0c17aef5d0f5e417e05f1e5d7b Mon Sep 17 00:00:00 2001 From: Tiberiu Chibici Date: Mon, 19 Aug 2019 13:47:36 +0300 Subject: [PATCH] Fixed bug where videos are checked multiple times during synchronization. Fixed some errors when manually managing videos. --- app/YtManagerApp/management/jobs/synchronize.py | 2 +- app/YtManagerApp/models.py | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/YtManagerApp/management/jobs/synchronize.py b/app/YtManagerApp/management/jobs/synchronize.py index a550c6c..eae3f80 100644 --- a/app/YtManagerApp/management/jobs/synchronize.py +++ b/app/YtManagerApp/management/jobs/synchronize.py @@ -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) diff --git a/app/YtManagerApp/models.py b/app/YtManagerApp/models.py index 2d0e771..7fe8265 100644 --- a/app/YtManagerApp/models.py +++ b/app/YtManagerApp/models.py @@ -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) -