Merge branch 'develop' into feature/stream
Conflicts: controllers/FrontController.php
This commit is contained in:
commit
c29285aaf1
6 changed files with 105 additions and 128 deletions
|
@ -40,23 +40,6 @@ class VideoDownload
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user agent used youtube-dl
|
||||
*
|
||||
* @return string UA
|
||||
* */
|
||||
public function getUA()
|
||||
{
|
||||
$this->procBuilder->setArguments(
|
||||
array(
|
||||
'--dump-user-agent'
|
||||
)
|
||||
);
|
||||
$process = $this->procBuilder->getProcess();
|
||||
$process->run();
|
||||
return trim($process->getOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* List all extractors
|
||||
*
|
||||
|
@ -74,30 +57,6 @@ class VideoDownload
|
|||
return explode(PHP_EOL, $process->getOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filename of video
|
||||
*
|
||||
* @param string $url URL of page
|
||||
* @param string $format Format to use for the video
|
||||
*
|
||||
* @return string Filename
|
||||
* */
|
||||
public function getFilename($url, $format = null)
|
||||
{
|
||||
$this->procBuilder->setArguments(
|
||||
array(
|
||||
'--get-filename',
|
||||
$url
|
||||
)
|
||||
);
|
||||
if (isset($format)) {
|
||||
$this->procBuilder->add('-f '.$format);
|
||||
}
|
||||
$process = $this->procBuilder->getProcess();
|
||||
$process->run();
|
||||
return trim($process->getOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all information about a video
|
||||
*
|
||||
|
|
|
@ -3,7 +3,7 @@ python: /usr/bin/python
|
|||
params:
|
||||
- --no-playlist
|
||||
- --no-warnings
|
||||
- -f best
|
||||
- -f best[protocol^=http]
|
||||
curl_params:
|
||||
convert: false
|
||||
avconv: vendor/bin/ffmpeg
|
||||
|
|
|
@ -113,7 +113,7 @@ class FrontController
|
|||
if (isset($params['audio'])) {
|
||||
try {
|
||||
try {
|
||||
return $this->getStream($params["url"], 'bestaudio', $response, $request);
|
||||
return $this->getStream($params["url"], 'bestaudio[protocol^=http]', $response, $request);
|
||||
} catch (\Exception $e) {
|
||||
$video = $this->download->getJSON($params["url"]);
|
||||
|
||||
|
|
|
@ -565,6 +565,10 @@ h1 {
|
|||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.monospace {
|
||||
font-family:monospace;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.thumb {
|
||||
width:90%;
|
||||
|
|
|
@ -26,25 +26,65 @@
|
|||
<h3><label for="format">Available formats:</label></h3>
|
||||
<form action="{path_for name="redirect"}">
|
||||
<input type="hidden" name="url" value="{$video->webpage_url}" />
|
||||
<select name="format" id="format">
|
||||
<option value="best">
|
||||
Best ({$video->ext})
|
||||
<select name="format" id="format" class="monospace">
|
||||
<optgroup label="Generic formats">
|
||||
<option value="best[protocol^=http]">
|
||||
{strip}
|
||||
Best ({$video->ext}
|
||||
{if isset($video->filesize)}
|
||||
{$video->filesize}
|
||||
{/if}
|
||||
)
|
||||
{/strip}
|
||||
</option>
|
||||
<option value="worst">
|
||||
<option value="worst[protocol^=http]">
|
||||
Worst
|
||||
</option>
|
||||
<optgroup label="Other formats">
|
||||
</optgroup>
|
||||
<optgroup label="Detailed formats" class="monospace">
|
||||
{foreach $video->formats as $format}
|
||||
{$format->protocol}
|
||||
{if $format->protocol|in_array:array('http', 'https')}
|
||||
{strip}
|
||||
<option value="{$format->format_id}">
|
||||
{$format->format} ({$format->ext})
|
||||
{$format->ext}
|
||||
{for $foo=1 to (5 - ($format->ext|strlen))}
|
||||
|
||||
{/for}
|
||||
{if isset($format->width)}
|
||||
{$format->width}x{$format->height}
|
||||
{for $foo=1 to (10 - (("{$format->width}x{$format->height}")|strlen))}
|
||||
|
||||
{/for}
|
||||
{else}
|
||||
{for $foo=1 to 10}
|
||||
|
||||
{/for}
|
||||
{/if}
|
||||
{if isset($format->filesize)}
|
||||
{($format->filesize/1000000)|round:2} MB
|
||||
{for $foo=1 to (7 - (($format->filesize/1000000)|round:2|strlen))}
|
||||
|
||||
{/for}
|
||||
{else}
|
||||
{for $foo=1 to 10}
|
||||
|
||||
{/for}
|
||||
{/if}
|
||||
{if isset($format->format_note)}
|
||||
{$format->format_note}
|
||||
{/if}
|
||||
({$format->format_id})
|
||||
</option>
|
||||
{/strip}
|
||||
{/if}
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
</select><br/><br/>
|
||||
<input class="downloadBtn" type="submit" value="Download" /><br/>
|
||||
</form>
|
||||
{else}
|
||||
<input type="hidden" name="format" value="best" />
|
||||
<input type="hidden" name="format" value="best[protocol^=http]" />
|
||||
<a class="downloadBtn"
|
||||
href="{$video->url|escape}">Download</a><br/>
|
||||
{/if}
|
||||
|
|
|
@ -33,17 +33,7 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* Test getUA function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetUA()
|
||||
{
|
||||
$this->assertStringStartsWith('Mozilla/', $this->download->getUA());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test listExtractors funtion
|
||||
* Test listExtractors function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -121,22 +111,6 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getFilename function
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
* @param string $result Expected filename
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider URLProvider
|
||||
*/
|
||||
public function testGetFilename($url, $format, $result)
|
||||
{
|
||||
$filename = $this->download->getFilename($url, $format);
|
||||
$this->assertEquals($filename, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getJSON function
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue