Skip to content

Commit

Permalink
TTK-26792 add more quality selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurujai committed Jan 23, 2024
1 parent 0a88c44 commit 5b8f46f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Command/ImportDownloadVideosFromYoutubeChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int

private function selectBestStreamFormat(DownloadOptions $downloadOptions): ?StreamFormat
{
$quality2160p = Utils::arrayFilterReset($downloadOptions->getAllFormats(), function ($format) {
return str_starts_with($format->mimeType, 'video') && !empty($format->audioQuality) && '2160p' === $format->qualityLabel;
});

$quality1440p = Utils::arrayFilterReset($downloadOptions->getAllFormats(), function ($format) {
return str_starts_with($format->mimeType, 'video') && !empty($format->audioQuality) && '1440p' === $format->qualityLabel;
});

$quality1080p = Utils::arrayFilterReset($downloadOptions->getAllFormats(), function ($format) {
return str_starts_with($format->mimeType, 'video') && !empty($format->audioQuality) && '1080p' === $format->qualityLabel;
});

$quality720p = Utils::arrayFilterReset($downloadOptions->getAllFormats(), function ($format) {
return str_starts_with($format->mimeType, 'video') && !empty($format->audioQuality) && '720p' === $format->qualityLabel;
});
Expand All @@ -158,7 +170,7 @@ private function selectBestStreamFormat(DownloadOptions $downloadOptions): ?Stre
return str_starts_with($format->mimeType, 'video') && !empty($format->audioQuality) && '240p' === $format->qualityLabel;
});

return $quality720p[0] ?? $quality360p[0] ?? $quality240p[0] ?? null;
return $quality2160p[0] ?? $quality1440p[0] ?? $quality1080p[0] ?? $quality720p[0] ?? $quality360p[0] ?? $quality240p[0] ?? null;
}

private function moveFileToStorage($item, $url, DownloadOptions $downloadOptions, string $channelId): void
Expand Down

0 comments on commit 5b8f46f

Please sign in to comment.