Use <select> for format list
This commit is contained in:
parent
24bf119a9c
commit
ed7018c957
3 changed files with 22 additions and 20 deletions
|
@ -226,7 +226,7 @@ class FrontController
|
||||||
$params = $request->getQueryParams();
|
$params = $request->getQueryParams();
|
||||||
if (isset($params["url"])) {
|
if (isset($params["url"])) {
|
||||||
try {
|
try {
|
||||||
$url = $this->download->getURL($params["url"]);
|
$url = $this->download->getURL($params["url"], $params["format"]);
|
||||||
return $response->withRedirect($url);
|
return $response->withRedirect($url);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$response->getBody()->write($e->getMessage());
|
$response->getBody()->write($e->getMessage());
|
||||||
|
|
|
@ -45,7 +45,7 @@ $app->get(
|
||||||
$app->get(
|
$app->get(
|
||||||
'/redirect',
|
'/redirect',
|
||||||
array($controller, 'redirect')
|
array($controller, 'redirect')
|
||||||
);
|
)->setName('redirect');
|
||||||
$app->get(
|
$app->get(
|
||||||
'/json',
|
'/json',
|
||||||
array($controller, 'json')
|
array($controller, 'json')
|
||||||
|
|
|
@ -23,24 +23,26 @@
|
||||||
{/if}
|
{/if}
|
||||||
<br/>
|
<br/>
|
||||||
{if isset($video->formats)}
|
{if isset($video->formats)}
|
||||||
<h3>Available formats:</h3>
|
<h3><label for="format">Available formats:</label></h3>
|
||||||
<p>(You might have to do a <i>Right click > Save as</i>)</p>
|
<form action="{path_for name="redirect"}">
|
||||||
<ul id="format" class="format">
|
<input type="hidden" name="url" value="{$video->webpage_url}" />
|
||||||
<li class="best" itemprop="encoding" itemscope
|
<select name="format" id="format">
|
||||||
itemtype="http://schema.org/VideoObject">
|
<option value="best">
|
||||||
<a download="{$video->_filename}" itemprop="contentUrl"
|
Best ({$video->ext})
|
||||||
href="{$video->url|escape}">
|
</option>
|
||||||
<b>Best</b> (<span itemprop="encodingFormat">{$video->ext}</span>)
|
<option value="worst">
|
||||||
</a></li>
|
Worst
|
||||||
|
</option>
|
||||||
|
<optgroup label="Other formats">
|
||||||
{foreach $video->formats as $format}
|
{foreach $video->formats as $format}
|
||||||
<li itemprop="encoding"
|
<option value="{$format->format_id}">
|
||||||
itemscope itemtype="http://schema.org/VideoObject">
|
{$format->format} ({$format->ext})
|
||||||
<a download="{$video->_filename|replace:$video->ext:$format->ext}" itemprop="contentUrl"
|
</option>
|
||||||
href="{$format->url|escape}">
|
|
||||||
<span itemprop="videoQuality">{$format->format}</span> (<span itemprop="encodingFormat">{$format->ext}</span>)
|
|
||||||
</a></li>
|
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</ul><br/><br/>
|
</optgroup>
|
||||||
|
</select><br/><br/>
|
||||||
|
<input class="downloadBtn" type="submit" value="Download" /><br/>
|
||||||
|
</form>
|
||||||
{else}
|
{else}
|
||||||
<input type="hidden" name="format" value="best" />
|
<input type="hidden" name="format" value="best" />
|
||||||
<a class="downloadBtn"
|
<a class="downloadBtn"
|
||||||
|
|
Loading…
Reference in a new issue