Some videos have no format

This commit is contained in:
Pierre Rudloff 2022-03-06 22:54:54 +01:00
parent edaf6f82c0
commit 113b3d5e50
1 changed files with 30 additions and 27 deletions

View File

@ -187,35 +187,38 @@ class FrontController extends BaseController
$formats[$genericFormatsLabel][$id] = $this->localeManager->t($genericFormat);
}
/** @var stdClass $format */
foreach ($this->video->getJson()->formats as $format) {
if ($this->config->stream || in_array($format->protocol, ['http', 'https'])) {
$formatParts = [
// File extension
$format->ext,
];
$json = $this->video->getJson();
if (isset($json->formats)) {
/** @var stdClass $format */
foreach ($json->formats as $format) {
if ($this->config->stream || in_array($format->protocol, ['http', 'https'])) {
$formatParts = [
// File extension
$format->ext,
];
if (isset($format->width) || isset($format->height)) {
// Video dimensions
$formatParts[] = implode('x', array_filter([$format->width, $format->height]));
if (isset($format->width) || isset($format->height)) {
// Video dimensions
$formatParts[] = implode('x', array_filter([$format->width, $format->height]));
}
if (isset($format->filesize)) {
// File size
$formatParts[] = round($format->filesize / 1000000, 2) . ' MB';
}
if (isset($format->format_note)) {
// Format name
$formatParts[] = $format->format_note;
}
if (isset($format->format_id)) {
// Format ID
$formatParts[] = '(' . $format->format_id . ')';
}
$formats[$detailedFormatsLabel][$format->format_id] = implode(' ', $formatParts);
}
if (isset($format->filesize)) {
// File size
$formatParts[] = round($format->filesize / 1000000, 2) . ' MB';
}
if (isset($format->format_note)) {
// Format name
$formatParts[] = $format->format_note;
}
if (isset($format->format_id)) {
// Format ID
$formatParts[] = '(' . $format->format_id . ')';
}
$formats[$detailedFormatsLabel][$format->format_id] = implode(' ', $formatParts);
}
}