refactor: Cleanup best format logic
Reuse $defaultFormat everywhere instead of duplicating conditions
This commit is contained in:
parent
506584ceee
commit
f315343798
2 changed files with 11 additions and 12 deletions
|
@ -97,9 +97,7 @@ class FrontController
|
||||||
$session_factory = new SessionFactory();
|
$session_factory = new SessionFactory();
|
||||||
$session = $session_factory->newInstance($cookies);
|
$session = $session_factory->newInstance($cookies);
|
||||||
$this->sessionSegment = $session->getSegment(self::class);
|
$this->sessionSegment = $session->getSegment(self::class);
|
||||||
if ($this->config->remux) {
|
if ($this->config->stream) {
|
||||||
$this->defaultFormat = 'bestvideo+bestaudio,best';
|
|
||||||
} elseif ($this->config->stream) {
|
|
||||||
$this->defaultFormat = 'best';
|
$this->defaultFormat = 'best';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,6 +321,7 @@ class FrontController
|
||||||
'config' => $this->config,
|
'config' => $this->config,
|
||||||
'canonical' => $this->getCanonicalUrl($request),
|
'canonical' => $this->getCanonicalUrl($request),
|
||||||
'locale' => $this->localeManager->getLocale(),
|
'locale' => $this->localeManager->getLocale(),
|
||||||
|
'defaultFormat' => $this->defaultFormat,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
<select name="format" id="format" class="formats monospace">
|
<select name="format" id="format" class="formats monospace">
|
||||||
<optgroup label="{t}Generic formats{/t}">
|
<optgroup label="{t}Generic formats{/t}">
|
||||||
<option value="{if $config->stream}best{else}best[protocol=https]/best[protocol=http]{/if}">
|
<option value="{$defaultFormat}">
|
||||||
{strip}
|
{strip}
|
||||||
{t}Best{/t} ({$video->ext})
|
{t}Best{/t} ({$video->ext})
|
||||||
{/strip}
|
{/strip}
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
{t}Remux best video with best audio{/t}
|
{t}Remux best video with best audio{/t}
|
||||||
</option>
|
</option>
|
||||||
{/if}
|
{/if}
|
||||||
<option value="{if $config->stream}worst{else}worst[protocol=https]/worst[protocol=http]{/if}">
|
<option value="{$defaultFormat|replace:best:worst}">
|
||||||
{t}Worst{/t}
|
{t}Worst{/t}
|
||||||
</option>
|
</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
|
|
Loading…
Reference in a new issue