Skip to content

Commit

Permalink
TTK-27357: Bundle migration to pmk5
Browse files Browse the repository at this point in the history
  • Loading branch information
albacodina committed Nov 19, 2024
1 parent e76e70b commit 7d98eb1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 44 deletions.
25 changes: 10 additions & 15 deletions Command/ImportJobsFromYouTubeDownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Command/ImportLivesFromYouTubeChannelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -51,7 +49,6 @@ public function __construct(
DocumentManager $documentManager,
GoogleAccountService $googleAccountService,
FactoryService $factoryService,
JobService $jobService,
i18nService $i18nService,
TagService $tagService,
MultimediaObjectPicService $multimediaObjectPicService,
Expand All @@ -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;
Expand Down
25 changes: 10 additions & 15 deletions Command/ImportVideosFromYouTubeChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -52,7 +54,7 @@ public function __construct(
DocumentManager $documentManager,
GoogleAccountService $googleAccountService,
FactoryService $factoryService,
JobService $jobService,
JobCreator $jobCreator,
i18nService $i18nService,
TagService $tagService,
MultimediaObjectPicService $multimediaObjectPicService,
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Command/YoutubeImportVideoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -35,7 +34,6 @@ class YoutubeImportVideoCommand extends Command
private $tagService;
private $youtubeService;
private $factoryService;
private $jobService;
private $profileService;
private $multimediaObjectPicService;
private $multimediaObjectEventDispatcherService;
Expand All @@ -45,7 +43,6 @@ public function __construct(
DocumentManager $documentManager,
TagService $tagService,
FactoryService $factoryService,
JobService $jobService,
ProfileService $profileService,
MultimediaObjectPicService $multimediaObjectPicService,
MultimediaObjectEventDispatcherService $multimediaObjectEventDispatcherService,
Expand All @@ -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;
Expand Down
14 changes: 9 additions & 5 deletions Services/VideoDataValidationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,7 +26,7 @@ class VideoDataValidationService extends CommonDataValidationService
{
private $documentManager;
private $youtubeConfigurationService;
private $jobService;
private $jobCreator;
private $tagService;
private $opencastService;
private $router;
Expand All @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit 7d98eb1

Please sign in to comment.