diff --git a/Command/ImportJobsFromYouTubeDownloadCommand.php b/Command/ImportJobsFromYouTubeDownloadCommand.php index c0bc321..5caf02d 100644 --- a/Command/ImportJobsFromYouTubeDownloadCommand.php +++ b/Command/ImportJobsFromYouTubeDownloadCommand.php @@ -6,9 +6,11 @@ use Doctrine\ODM\MongoDB\DocumentManager; use Pumukit\CoreBundle\Utils\FinderUtils; -use Pumukit\EncoderBundle\Services\JobService; +use Pumukit\EncoderBundle\Services\DTO\JobOptions; +use Pumukit\EncoderBundle\Services\JobCreator; use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Tag; +use Pumukit\SchemaBundle\Document\ValueObject\Path; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputInterface; @@ -20,18 +22,18 @@ final class ImportJobsFromYouTubeDownloadCommand extends Command public const DEFAULT_PROFILE_ENCODER = 'broadcastable_master'; private DocumentManager $documentManager; - private JobService $jobService; + private $jobCreator; private string $tempDir; private string $channelId; private $youtubeErrors = []; public function __construct( DocumentManager $documentManager, - JobService $jobService, + JobCreator $jobCreator, string $tempDir ) { $this->documentManager = $documentManager; - $this->jobService = $jobService; + $this->jobCreator = $jobCreator; $this->tempDir = $tempDir; parent::__construct(); } @@ -105,17 +107,10 @@ private function addJob(MultimediaObject $multimediaObject, string $youtubeId): return $multimediaObject; } - return $this->jobService->createTrackFromInboxOnServer( - $multimediaObject, - $trackUrl, - self::DEFAULT_PROFILE_ENCODER, - 0, - null, - '', - [], - 0, - 0 - ); + $jobOptions = new JobOptions(self::DEFAULT_PROFILE_ENCODER, 0, null, [], []); + $path = Path::create($trackUrl); + + return $this->jobCreator->fromPath($multimediaObject, $path, $jobOptions); } private function ensureYouTubeAccountExists(InputInterface $input): void diff --git a/Command/ImportLivesFromYouTubeChannelCommand.php b/Command/ImportLivesFromYouTubeChannelCommand.php index 518148f..713ffaf 100644 --- a/Command/ImportLivesFromYouTubeChannelCommand.php +++ b/Command/ImportLivesFromYouTubeChannelCommand.php @@ -8,7 +8,6 @@ use Google\Service\YouTube\Video; use Google\Service\YouTube\VideoListResponse; use Pumukit\CoreBundle\Services\i18nService; -use Pumukit\EncoderBundle\Services\JobService; use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Series; use Pumukit\SchemaBundle\Document\Tag; @@ -35,7 +34,6 @@ final class ImportLivesFromYouTubeChannelCommand extends Command private DocumentManager $documentManager; private GoogleAccountService $googleAccountService; private FactoryService $factoryService; - private JobService $jobService; private i18nService $i18nService; private TagService $tagService; @@ -51,7 +49,6 @@ public function __construct( DocumentManager $documentManager, GoogleAccountService $googleAccountService, FactoryService $factoryService, - JobService $jobService, i18nService $i18nService, TagService $tagService, MultimediaObjectPicService $multimediaObjectPicService, @@ -61,7 +58,6 @@ public function __construct( $this->documentManager = $documentManager; $this->googleAccountService = $googleAccountService; $this->factoryService = $factoryService; - $this->jobService = $jobService; $this->i18nService = $i18nService; $this->tagService = $tagService; $this->multimediaObjectPicService = $multimediaObjectPicService; diff --git a/Command/ImportVideosFromYouTubeChannel.php b/Command/ImportVideosFromYouTubeChannel.php index 81fb776..aa606b6 100644 --- a/Command/ImportVideosFromYouTubeChannel.php +++ b/Command/ImportVideosFromYouTubeChannel.php @@ -9,10 +9,12 @@ use Google\Service\YouTube\VideoListResponse; use Pumukit\CoreBundle\Services\i18nService; use Pumukit\CoreBundle\Utils\FinderUtils; -use Pumukit\EncoderBundle\Services\JobService; +use Pumukit\EncoderBundle\Services\DTO\JobOptions; +use Pumukit\EncoderBundle\Services\JobCreator; use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Series; use Pumukit\SchemaBundle\Document\Tag; +use Pumukit\SchemaBundle\Document\ValueObject\Path; use Pumukit\SchemaBundle\Services\FactoryService; use Pumukit\SchemaBundle\Services\MultimediaObjectPicService; use Pumukit\SchemaBundle\Services\TagService; @@ -36,7 +38,7 @@ final class ImportVideosFromYouTubeChannel extends Command private DocumentManager $documentManager; private GoogleAccountService $googleAccountService; private FactoryService $factoryService; - private JobService $jobService; + private $jobCreator; private i18nService $i18nService; private TagService $tagService; @@ -52,7 +54,7 @@ public function __construct( DocumentManager $documentManager, GoogleAccountService $googleAccountService, FactoryService $factoryService, - JobService $jobService, + JobCreator $jobCreator, i18nService $i18nService, TagService $tagService, MultimediaObjectPicService $multimediaObjectPicService, @@ -62,7 +64,7 @@ public function __construct( $this->documentManager = $documentManager; $this->googleAccountService = $googleAccountService; $this->factoryService = $factoryService; - $this->jobService = $jobService; + $this->jobCreator = $jobCreator; $this->i18nService = $i18nService; $this->tagService = $tagService; $this->multimediaObjectPicService = $multimediaObjectPicService; @@ -272,17 +274,10 @@ private function addJob(MultimediaObject $multimediaObject, string $youtubeId): $priority = 0; $language = null; - return $this->jobService->createTrackFromInboxOnServer( - $multimediaObject, - $trackUrl, - $profile, - $priority, - $language, - $description = '', - $initVars = [], - $duration = 0, - $flags = 0 - ); + $jobOptions = new JobOptions($profile, $priority, $language, [], []); + $path = Path::create($trackUrl); + + return $this->jobCreator->fromPath($multimediaObject, $path, $jobOptions); } private function videoInfo(\Google_Service_YouTube $service, string $videoId): VideoListResponse diff --git a/Command/YoutubeImportVideoCommand.php b/Command/YoutubeImportVideoCommand.php index 70fce60..da0770c 100644 --- a/Command/YoutubeImportVideoCommand.php +++ b/Command/YoutubeImportVideoCommand.php @@ -6,7 +6,6 @@ use Doctrine\ODM\MongoDB\DocumentManager; use Psr\Log\LoggerInterface; -use Pumukit\EncoderBundle\Services\JobService; use Pumukit\EncoderBundle\Services\ProfileService; use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Pic; @@ -35,7 +34,6 @@ class YoutubeImportVideoCommand extends Command private $tagService; private $youtubeService; private $factoryService; - private $jobService; private $profileService; private $multimediaObjectPicService; private $multimediaObjectEventDispatcherService; @@ -45,7 +43,6 @@ public function __construct( DocumentManager $documentManager, TagService $tagService, FactoryService $factoryService, - JobService $jobService, ProfileService $profileService, MultimediaObjectPicService $multimediaObjectPicService, MultimediaObjectEventDispatcherService $multimediaObjectEventDispatcherService, @@ -54,7 +51,6 @@ public function __construct( $this->documentManager = $documentManager; $this->tagService = $tagService; $this->factoryService = $factoryService; - $this->jobService = $jobService; $this->profileService = $profileService; $this->multimediaObjectPicService = $multimediaObjectPicService; $this->multimediaObjectEventDispatcherService = $multimediaObjectEventDispatcherService; diff --git a/Services/VideoDataValidationService.php b/Services/VideoDataValidationService.php index 9fa8719..8be381d 100644 --- a/Services/VideoDataValidationService.php +++ b/Services/VideoDataValidationService.php @@ -8,12 +8,14 @@ use MongoDB\BSON\ObjectId; use Psr\Log\LoggerInterface; use Pumukit\EncoderBundle\Document\Job; -use Pumukit\EncoderBundle\Services\JobService; +use Pumukit\EncoderBundle\Services\DTO\JobOptions; +use Pumukit\EncoderBundle\Services\JobCreator; use Pumukit\OpencastBundle\Services\OpencastService; use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Person; use Pumukit\SchemaBundle\Document\Tag; use Pumukit\SchemaBundle\Document\Track; +use Pumukit\SchemaBundle\Document\ValueObject\Path; use Pumukit\SchemaBundle\Services\TagService; use Pumukit\YoutubeBundle\PumukitYoutubeBundle; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -24,7 +26,7 @@ class VideoDataValidationService extends CommonDataValidationService { private $documentManager; private $youtubeConfigurationService; - private $jobService; + private $jobCreator; private $tagService; private $opencastService; private $router; @@ -35,7 +37,7 @@ class VideoDataValidationService extends CommonDataValidationService public function __construct( DocumentManager $documentManager, YoutubeConfigurationService $youtubeConfigurationService, - JobService $jobService, + JobCreator $jobCreator, TagService $tagService, OpencastService $opencastService = null, RouterInterface $router, @@ -45,7 +47,7 @@ public function __construct( ) { $this->documentManager = $documentManager; $this->youtubeConfigurationService = $youtubeConfigurationService; - $this->jobService = $jobService; + $this->jobCreator = $jobCreator; $this->tagService = $tagService; $this->opencastService = $opencastService; $this->router = $router; @@ -229,7 +231,9 @@ protected function generateSbsTrack(MultimediaObject $multimediaObject) $track = $tracks[0]; $path = $track->getPath(); $language = $track->getLanguage() ?: \Locale::getDefault(); - $job = $this->jobService->addJob($path, $this->youtubeConfigurationService->sbsProfileName(), 2, $multimediaObject, $language, [], [], $track->getDuration()); + $jobOptions = new JobOptions($this->youtubeConfigurationService->sbsProfileName(), 2, $language, [], [], $track->getDuration()); + $path = Path::create($path); + $job = $this->jobCreator->fromPath($multimediaObject, $path, $jobOptions); } return 0; diff --git a/composer.json b/composer.json index 7cb1059..92ded50 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ ], "require": { "php": "^8.2", - "pumukit/pumukit": ">4.0", + "pumukit/pumukit": "^5.0", "google/apiclient" : "^2.0", "athlon1600/youtube-downloader": "^4.0" },