From 5448f532b85333092ba44464a1364eed330df17f Mon Sep 17 00:00:00 2001 From: Pablo Ogando Ferreira Date: Fri, 8 Mar 2024 12:19:38 +0100 Subject: [PATCH] TTK-26902 add use --- Command/ImportJobsFromYouTubeDownloadCommand.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Command/ImportJobsFromYouTubeDownloadCommand.php b/Command/ImportJobsFromYouTubeDownloadCommand.php index 72421c3..4b66156 100644 --- a/Command/ImportJobsFromYouTubeDownloadCommand.php +++ b/Command/ImportJobsFromYouTubeDownloadCommand.php @@ -8,6 +8,7 @@ use Pumukit\CoreBundle\Utils\FinderUtils; use Pumukit\EncoderBundle\Services\JobService; use Pumukit\SchemaBundle\Document\MultimediaObject; +use Pumukit\SchemaBundle\Document\Tag; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputInterface; @@ -62,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $channel = $input->getOption('channel'); $limit = (int) $input->getOption('limit') ?? null; - $youtubeAccount = $this->ensureYouTubeAccountExists($input); + $this->ensureYouTubeAccountExists($input); $multimediaObjects = $this->documentManager->getRepository(MultimediaObject::class)->findBy([ 'status' => ['$in' => [MultimediaObject::STATUS_PUBLISHED, MultimediaObject::STATUS_HIDDEN]], @@ -116,4 +117,15 @@ private function addJob(MultimediaObject $multimediaObject, string $youtubeId): 0 ); } + + private function ensureYouTubeAccountExists(InputInterface $input): void + { + $youtubeAccount = $this->documentManager->getRepository(Tag::class)->findOneBy([ + 'properties.login' => $input->getOption('account'), + ]); + + if (!$youtubeAccount) { + throw new \Exception('Account not found'); + } + } }