getURL() should not return an array
This commit is contained in:
parent
f7f0a7b7f4
commit
f14bec35ea
3 changed files with 13 additions and 11 deletions
|
@ -104,7 +104,7 @@ class VideoDownload
|
|||
* @param string $url URL of page
|
||||
* @param string $format Format to use for the video
|
||||
*
|
||||
* @return string JSON
|
||||
* @return object Decoded JSON
|
||||
* */
|
||||
public function getJSON($url, $format = null)
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ class VideoDownload
|
|||
if (!$process->isSuccessful()) {
|
||||
throw new \Exception($process->getErrorOutput());
|
||||
} else {
|
||||
return array('success'=>true, 'url'=>$process->getOutput());
|
||||
return $process->getOutput();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -225,8 +225,8 @@ class FrontController
|
|||
global $app;
|
||||
if (isset($_GET["url"])) {
|
||||
try {
|
||||
$video = $this->download->getURL($_GET["url"]);
|
||||
return $response->withRedirect($video['url']);
|
||||
$url = $this->download->getURL($_GET["url"]);
|
||||
return $response->withRedirect($url);
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
return $response->withHeader('Content-Type', 'text/plain');
|
||||
|
|
|
@ -62,11 +62,10 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
|||
* @return void
|
||||
* @dataProvider urlProvider
|
||||
*/
|
||||
public function testGetURL($url, $format)
|
||||
public function testGetURL($url, $format, $filename, $domain)
|
||||
{
|
||||
$videoURL = $this->download->getURL($url, $format);
|
||||
$this->assertArrayHasKey('success', $videoURL);
|
||||
$this->assertArrayHasKey('url', $videoURL);
|
||||
$this->assertContains($domain, $videoURL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,7 +79,7 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testGetURLError($url)
|
||||
{
|
||||
$videoURL = $this->download->getURL($url);
|
||||
$this->download->getURL($url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,16 +92,19 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
|||
return array(
|
||||
array(
|
||||
'https://www.youtube.com/watch?v=M7IpKCZ47pU', null,
|
||||
"It's Not Me, It's You - Hearts Under Fire-M7IpKCZ47pU.mp4"
|
||||
"It's Not Me, It's You - Hearts Under Fire-M7IpKCZ47pU.mp4",
|
||||
'googlevideo.com'
|
||||
),
|
||||
array(
|
||||
'https://www.youtube.com/watch?v=RJJ6FCAXvKg', 22,
|
||||
"'Heart Attack' - Demi Lovato ".
|
||||
"(Sam Tsui & Against The Current)-RJJ6FCAXvKg.mp4"
|
||||
"(Sam Tsui & Against The Current)-RJJ6FCAXvKg.mp4",
|
||||
'googlevideo.com'
|
||||
),
|
||||
array(
|
||||
'https://vimeo.com/24195442', null,
|
||||
"Carving the Mountains-24195442.mp4"
|
||||
"Carving the Mountains-24195442.mp4",
|
||||
'vimeocdn.com'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue