From e464dd34f9619d8ebcae52b03bb5995ed74228bc Mon Sep 17 00:00:00 2001 From: Pablo Ogando Ferreira Date: Wed, 24 Jan 2024 16:17:49 +0100 Subject: [PATCH] TTK-26792 check if conditions allowed download files --- .../GenerateMultimediaObjectByYouTubeAPICommand.php | 2 +- Command/ImportDownloadVideosFromYoutubeChannel.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Command/GenerateMultimediaObjectByYouTubeAPICommand.php b/Command/GenerateMultimediaObjectByYouTubeAPICommand.php index 0e3d17b..95379cb 100644 --- a/Command/GenerateMultimediaObjectByYouTubeAPICommand.php +++ b/Command/GenerateMultimediaObjectByYouTubeAPICommand.php @@ -226,7 +226,7 @@ private function ensureMultimediaObjectExists(Series $series, string $videoId): private function autocompleteMultimediaObjectMetadata(MultimediaObject $multimediaObject, DownloadOptions $downloadOptions) { $youtubeInfo = $downloadOptions->getInfo(); - $text = $this->generateTextWithLocales($youtubeInfo->id); + $text = $this->generateTextWithLocales($youtubeInfo->title); $multimediaObject->setI18nTitle($text); $text = $this->generateTextWithLocales($youtubeInfo->description); $multimediaObject->setI18nDescription($text); diff --git a/Command/ImportDownloadVideosFromYoutubeChannel.php b/Command/ImportDownloadVideosFromYoutubeChannel.php index 9e0dfc0..c8a12f0 100644 --- a/Command/ImportDownloadVideosFromYoutubeChannel.php +++ b/Command/ImportDownloadVideosFromYoutubeChannel.php @@ -5,6 +5,8 @@ namespace Pumukit\YoutubeBundle\Command; use Doctrine\ODM\MongoDB\DocumentManager; +use Pumukit\EncoderBundle\Document\Job; +use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Tag; use Pumukit\YoutubeBundle\Services\GoogleAccountService; use Symfony\Component\Console\Command\Command; @@ -203,7 +205,16 @@ private function moveFileToStorage($item, $url, DownloadOptions $downloadOptions $this->createChannelDir($channelId); $file = $this->tempDir.'/'.$channelId.'/'.$videoId.'.'.$mimeType; - if (file_exists($file)) { + $multimediaObject = $this->documentManager->getRepository(MultimediaObject::class)->findOneBy([ + 'properties.youtube_video_id' => $videoId, + ]); + + $failedJobs = $this->documentManager->getRepository(Job::class)->findOneBy([ + 'status' => Job::STATUS_ERROR, + 'mm_id' => $multimediaObject, + ]); + + if (!file_exists($file) && $multimediaObject instanceof MultimediaObject && !$failedJobs instanceof Job) { return; }