File indexing completed on 2024-04-28 15:39:48
0001 // SPDX-FileCopyrightText: 2012-2022 The KPhotoAlbum Development Team 0002 // 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 #include "SearchForVideosWithoutVideoThumbnailsJob.h" 0006 0007 #include "ExtractOneThumbnailJob.h" 0008 #include "HandleVideoThumbnailRequestJob.h" 0009 #include "ReadVideoLengthJob.h" 0010 0011 #include <BackgroundTaskManager/JobInfo.h> 0012 #include <BackgroundTaskManager/JobManager.h> 0013 #include <DB/ImageDB.h> 0014 #include <DB/ImageInfo.h> 0015 0016 #include <KLocalizedString> 0017 #include <QFile> 0018 0019 using namespace BackgroundJobs; 0020 0021 void BackgroundJobs::SearchForVideosWithoutVideoThumbnailsJob::execute() 0022 { 0023 const auto images = DB::ImageDB::instance()->images(); 0024 0025 for (const auto &info : images) { 0026 if (!info->isVideo()) 0027 continue; 0028 0029 // silently ignore videos not (currently) on disk: 0030 if (!info->fileName().exists()) 0031 continue; 0032 0033 const DB::FileName thumbnailName = BackgroundJobs::HandleVideoThumbnailRequestJob::frameName(info->fileName(), 9); 0034 if (thumbnailName.exists()) 0035 continue; 0036 0037 BackgroundJobs::ReadVideoLengthJob *readVideoLengthJob = new BackgroundJobs::ReadVideoLengthJob(info->fileName(), BackgroundTaskManager::BackgroundVideoPreviewRequest); 0038 0039 for (int i = 0; i < 10; ++i) { 0040 ExtractOneThumbnailJob *extractJob = new ExtractOneThumbnailJob(info->fileName(), i, BackgroundTaskManager::BackgroundVideoPreviewRequest); 0041 extractJob->addDependency(readVideoLengthJob); 0042 } 0043 0044 BackgroundTaskManager::JobManager::instance()->addJob(readVideoLengthJob); 0045 } 0046 Q_EMIT completed(); 0047 } 0048 0049 QString BackgroundJobs::SearchForVideosWithoutVideoThumbnailsJob::title() const 0050 { 0051 return i18n("Searching for videos without video thumbnails"); 0052 } 0053 0054 QString BackgroundJobs::SearchForVideosWithoutVideoThumbnailsJob::details() const 0055 { 0056 return QString(); 0057 } 0058 0059 SearchForVideosWithoutVideoThumbnailsJob::SearchForVideosWithoutVideoThumbnailsJob() 0060 : JobInterface(BackgroundTaskManager::BackgroundVideoPreviewRequest) 0061 { 0062 } 0063 0064 // vi:expandtab:tabstop=4 shiftwidth=4: 0065 0066 #include "moc_SearchForVideosWithoutVideoThumbnailsJob.cpp"