Merge branch 'develop' into feature/stream

Conflicts:
	controllers/FrontController.php
This commit is contained in:
Pierre Rudloff 2016-04-11 01:22:01 +02:00
commit c29285aaf1
6 changed files with 105 additions and 128 deletions

View file

@ -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 * List all extractors
* *
@ -74,30 +57,6 @@ class VideoDownload
return explode(PHP_EOL, $process->getOutput()); 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 * Get all information about a video
* *

View file

@ -3,7 +3,7 @@ python: /usr/bin/python
params: params:
- --no-playlist - --no-playlist
- --no-warnings - --no-warnings
- -f best - -f best[protocol^=http]
curl_params: curl_params:
convert: false convert: false
avconv: vendor/bin/ffmpeg avconv: vendor/bin/ffmpeg

View file

@ -113,7 +113,7 @@ class FrontController
if (isset($params['audio'])) { if (isset($params['audio'])) {
try { try {
try { try {
return $this->getStream($params["url"], 'bestaudio', $response, $request); return $this->getStream($params["url"], 'bestaudio[protocol^=http]', $response, $request);
} catch (\Exception $e) { } catch (\Exception $e) {
$video = $this->download->getJSON($params["url"]); $video = $this->download->getJSON($params["url"]);

View file

@ -565,6 +565,10 @@ h1 {
margin-bottom: 1em; margin-bottom: 1em;
} }
.monospace {
font-family:monospace;
}
@media (max-width: 640px) { @media (max-width: 640px) {
.thumb { .thumb {
width:90%; width:90%;

View file

@ -26,25 +26,65 @@
<h3><label for="format">Available formats:</label></h3> <h3><label for="format">Available formats:</label></h3>
<form action="{path_for name="redirect"}"> <form action="{path_for name="redirect"}">
<input type="hidden" name="url" value="{$video->webpage_url}" /> <input type="hidden" name="url" value="{$video->webpage_url}" />
<select name="format" id="format"> <select name="format" id="format" class="monospace">
<option value="best"> <optgroup label="Generic formats">
Best ({$video->ext}) <option value="best[protocol^=http]">
{strip}
Best ({$video->ext}
{if isset($video->filesize)}
{$video->filesize}
{/if}
)
{/strip}
</option> </option>
<option value="worst"> <option value="worst[protocol^=http]">
Worst Worst
</option> </option>
<optgroup label="Other formats"> </optgroup>
<optgroup label="Detailed formats" class="monospace">
{foreach $video->formats as $format} {foreach $video->formats as $format}
{$format->protocol}
{if $format->protocol|in_array:array('http', 'https')}
{strip}
<option value="{$format->format_id}"> <option value="{$format->format_id}">
{$format->format} ({$format->ext}) {$format->ext}
{for $foo=1 to (5 - ($format->ext|strlen))}
&nbsp;
{/for}
{if isset($format->width)}
{$format->width}x{$format->height}
{for $foo=1 to (10 - (("{$format->width}x{$format->height}")|strlen))}
&nbsp;
{/for}
{else}
{for $foo=1 to 10}
&nbsp;
{/for}
{/if}
{if isset($format->filesize)}
{($format->filesize/1000000)|round:2} MB
{for $foo=1 to (7 - (($format->filesize/1000000)|round:2|strlen))}
&nbsp;
{/for}
{else}
{for $foo=1 to 10}
&nbsp;
{/for}
{/if}
{if isset($format->format_note)}
{$format->format_note}
{/if}
&nbsp;({$format->format_id})
</option> </option>
{/strip}
{/if}
{/foreach} {/foreach}
</optgroup> </optgroup>
</select><br/><br/> </select><br/><br/>
<input class="downloadBtn" type="submit" value="Download" /><br/> <input class="downloadBtn" type="submit" value="Download" /><br/>
</form> </form>
{else} {else}
<input type="hidden" name="format" value="best" /> <input type="hidden" name="format" value="best[protocol^=http]" />
<a class="downloadBtn" <a class="downloadBtn"
href="{$video->url|escape}">Download</a><br/> href="{$video->url|escape}">Download</a><br/>
{/if} {/if}

View file

@ -33,17 +33,7 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* Test getUA function * Test listExtractors function
*
* @return void
*/
public function testGetUA()
{
$this->assertStringStartsWith('Mozilla/', $this->download->getUA());
}
/**
* Test listExtractors funtion
* *
* @return void * @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 * Test getJSON function
* *