Skip to content

Commit

Permalink
TTK-26902 add use
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurujai committed Mar 8, 2024
1 parent d4ba447 commit 5448f53
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Command/ImportJobsFromYouTubeDownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]],
Expand Down Expand Up @@ -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');
}
}
}

0 comments on commit 5448f53

Please sign in to comment.