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); $formats[$genericFormatsLabel][$id] = $this->localeManager->t($genericFormat);
} }
/** @var stdClass $format */ $json = $this->video->getJson();
foreach ($this->video->getJson()->formats as $format) { if (isset($json->formats)) {
if ($this->config->stream || in_array($format->protocol, ['http', 'https'])) { /** @var stdClass $format */
$formatParts = [ foreach ($json->formats as $format) {
// File extension if ($this->config->stream || in_array($format->protocol, ['http', 'https'])) {
$format->ext, $formatParts = [
]; // File extension
$format->ext,
];
if (isset($format->width) || isset($format->height)) { if (isset($format->width) || isset($format->height)) {
// Video dimensions // Video dimensions
$formatParts[] = implode('x', array_filter([$format->width, $format->height])); $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);
} }
} }