1 /* SPDX-FileCopyrightText: 2012-2020 The KPhotoAlbum Development Team 2 3 SPDX-License-Identifier: GPL-2.0-or-later 4 */ 5 6 #include "SearchForVideosWithoutVideoThumbnailsJob.h" 7 8 #include "ExtractOneThumbnailJob.h" 9 #include "HandleVideoThumbnailRequestJob.h" 10 #include "ReadVideoLengthJob.h" 11 12 #include <BackgroundTaskManager/JobInfo.h> 13 #include <BackgroundTaskManager/JobManager.h> 14 #include <DB/ImageDB.h> 15 #include <DB/ImageInfo.h> 16 17 #include <KLocalizedString> 18 #include <QFile> 19 20 using namespace BackgroundJobs; 21 execute()22void BackgroundJobs::SearchForVideosWithoutVideoThumbnailsJob::execute() 23 { 24 const auto images = DB::ImageDB::instance()->images(); 25 26 for (const auto &info : images) { 27 if (!info->isVideo()) 28 continue; 29 30 // silently ignore videos not (currently) on disk: 31 if (!info->fileName().exists()) 32 continue; 33 34 const DB::FileName thumbnailName = BackgroundJobs::HandleVideoThumbnailRequestJob::frameName(info->fileName(), 9); 35 if (thumbnailName.exists()) 36 continue; 37 38 BackgroundJobs::ReadVideoLengthJob *readVideoLengthJob = new BackgroundJobs::ReadVideoLengthJob(info->fileName(), BackgroundTaskManager::BackgroundVideoPreviewRequest); 39 40 for (int i = 0; i < 10; ++i) { 41 ExtractOneThumbnailJob *extractJob = new ExtractOneThumbnailJob(info->fileName(), i, BackgroundTaskManager::BackgroundVideoPreviewRequest); 42 extractJob->addDependency(readVideoLengthJob); 43 } 44 45 BackgroundTaskManager::JobManager::instance()->addJob(readVideoLengthJob); 46 } 47 emit completed(); 48 } 49 title() const50QString BackgroundJobs::SearchForVideosWithoutVideoThumbnailsJob::title() const 51 { 52 return i18n("Searching for videos without video thumbnails"); 53 } 54 details() const55QString BackgroundJobs::SearchForVideosWithoutVideoThumbnailsJob::details() const 56 { 57 return QString(); 58 } 59 SearchForVideosWithoutVideoThumbnailsJob()60SearchForVideosWithoutVideoThumbnailsJob::SearchForVideosWithoutVideoThumbnailsJob() 61 : JobInterface(BackgroundTaskManager::BackgroundVideoPreviewRequest) 62 { 63 } 64 65 // vi:expandtab:tabstop=4 shiftwidth=4: 66