Merged some fixes from private.coffee
This commit is contained in:
parent
adbc9d29d9
commit
912aa99054
3 changed files with 21 additions and 5 deletions
|
@ -44,7 +44,13 @@ class DownloadController extends BaseController
|
|||
{
|
||||
$url = $this->getVideoPageUrl($request);
|
||||
|
||||
$this->video = $this->downloader->getVideo($url, $this->getFormat($request), $this->getPassword($request));
|
||||
$format = $this->getFormat($request);
|
||||
|
||||
if ($this->config->remux && $request->getQueryParam('remux')) {
|
||||
$this->video = $this->downloader->getVideo($url, $format . "+bestaudio", $this->getPassword($request));
|
||||
} else {
|
||||
$this->video = $this->downloader->getVideo($url, $format, $this->getPassword($request));
|
||||
}
|
||||
|
||||
try {
|
||||
if ($this->config->convert && $request->getQueryParam('audio')) {
|
||||
|
@ -106,6 +112,8 @@ class DownloadController extends BaseController
|
|||
$to = $request->getQueryParam('to');
|
||||
}
|
||||
|
||||
assert((is_string($from) || is_null($from)) && (is_string($to) || is_null($to)));
|
||||
|
||||
$response = $response->withHeader(
|
||||
'Content-Disposition',
|
||||
'attachment; filename="' .
|
||||
|
@ -270,12 +278,12 @@ class DownloadController extends BaseController
|
|||
$videoUrls = $this->video->getUrl();
|
||||
} catch (EmptyUrlException $e) {
|
||||
/*
|
||||
If this happens it is probably a playlist
|
||||
so it will either be handled by getStream() or throw an exception anyway.
|
||||
* If this happens it is probably a playlist
|
||||
* so it will either be handled by getStream() or throw an exception anyway.
|
||||
*/
|
||||
$videoUrls = [];
|
||||
}
|
||||
if (count($videoUrls) > 1) {
|
||||
if (count($videoUrls) > 1 && !isset($this->video->entries)) {
|
||||
return $this->getRemuxStream($request, $response);
|
||||
} elseif ($this->config->stream && (isset($this->video->entries) || $request->getQueryParam('stream'))) {
|
||||
return $this->getStream($request, $response);
|
||||
|
@ -305,6 +313,9 @@ class DownloadController extends BaseController
|
|||
*/
|
||||
private function getConvertedResponse(Request $request, Response $response): Response
|
||||
{
|
||||
assert(is_string($request->getQueryParam('customFormat')));
|
||||
assert(is_int($request->getQueryParam('customBitrate')));
|
||||
|
||||
$response = $response->withHeader(
|
||||
'Content-Disposition',
|
||||
'attachment; filename="' .
|
||||
|
@ -316,7 +327,7 @@ class DownloadController extends BaseController
|
|||
$process = $this->downloader->getConvertedStream(
|
||||
$this->video,
|
||||
$request->getQueryParam('customBitrate'),
|
||||
$request->getQueryParam('customFormat')
|
||||
$request->getQueryParam('customFormat')
|
||||
);
|
||||
$response = $response->withBody(new Stream($process));
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ class CspMiddleware
|
|||
->addDirective('font-src', ['self' => true])
|
||||
->addDirective('style-src', ['self' => true])
|
||||
->addDirective('manifest-src', ['self' => true])
|
||||
->addDirective('img-src', ['self' => true])
|
||||
->addDirective('base-uri', [])
|
||||
->addDirective('frame-ancestors', [])
|
||||
->addSource('form-action', '*')
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
{html_options name='format' options=$formats selected=$defaultFormat id="format" class="formats monospace"}
|
||||
<br/>
|
||||
<br/>
|
||||
<input type="checkbox" checked name="remux" id="remux" value="1"/>
|
||||
<label for="remux">{t}Remux with best audio{/t}</label>
|
||||
<br/>
|
||||
<br/>
|
||||
{/if}
|
||||
{if $config->stream}
|
||||
<input type="checkbox" {if $config->stream !== 'ask'}checked{/if} name="stream" id="stream"/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue