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 $url URL of page
|
||||||
* @param string $format Format to use for the video
|
* @param string $format Format to use for the video
|
||||||
*
|
*
|
||||||
* @return string JSON
|
* @return object Decoded JSON
|
||||||
* */
|
* */
|
||||||
public function getJSON($url, $format = null)
|
public function getJSON($url, $format = null)
|
||||||
{
|
{
|
||||||
|
@ -150,7 +150,7 @@ class VideoDownload
|
||||||
if (!$process->isSuccessful()) {
|
if (!$process->isSuccessful()) {
|
||||||
throw new \Exception($process->getErrorOutput());
|
throw new \Exception($process->getErrorOutput());
|
||||||
} else {
|
} else {
|
||||||
return array('success'=>true, 'url'=>$process->getOutput());
|
return $process->getOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,8 +225,8 @@ class FrontController
|
||||||
global $app;
|
global $app;
|
||||||
if (isset($_GET["url"])) {
|
if (isset($_GET["url"])) {
|
||||||
try {
|
try {
|
||||||
$video = $this->download->getURL($_GET["url"]);
|
$url = $this->download->getURL($_GET["url"]);
|
||||||
return $response->withRedirect($video['url']);
|
return $response->withRedirect($url);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo $e->getMessage().PHP_EOL;
|
echo $e->getMessage().PHP_EOL;
|
||||||
return $response->withHeader('Content-Type', 'text/plain');
|
return $response->withHeader('Content-Type', 'text/plain');
|
||||||
|
|
|
@ -62,11 +62,10 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
||||||
* @return void
|
* @return void
|
||||||
* @dataProvider urlProvider
|
* @dataProvider urlProvider
|
||||||
*/
|
*/
|
||||||
public function testGetURL($url, $format)
|
public function testGetURL($url, $format, $filename, $domain)
|
||||||
{
|
{
|
||||||
$videoURL = $this->download->getURL($url, $format);
|
$videoURL = $this->download->getURL($url, $format);
|
||||||
$this->assertArrayHasKey('success', $videoURL);
|
$this->assertContains($domain, $videoURL);
|
||||||
$this->assertArrayHasKey('url', $videoURL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +79,7 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testGetURLError($url)
|
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(
|
return array(
|
||||||
array(
|
array(
|
||||||
'https://www.youtube.com/watch?v=M7IpKCZ47pU', null,
|
'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(
|
array(
|
||||||
'https://www.youtube.com/watch?v=RJJ6FCAXvKg', 22,
|
'https://www.youtube.com/watch?v=RJJ6FCAXvKg', 22,
|
||||||
"'Heart Attack' - Demi Lovato ".
|
"'Heart Attack' - Demi Lovato ".
|
||||||
"(Sam Tsui & Against The Current)-RJJ6FCAXvKg.mp4"
|
"(Sam Tsui & Against The Current)-RJJ6FCAXvKg.mp4",
|
||||||
|
'googlevideo.com'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'https://vimeo.com/24195442', null,
|
'https://vimeo.com/24195442', null,
|
||||||
"Carving the Mountains-24195442.mp4"
|
"Carving the Mountains-24195442.mp4",
|
||||||
|
'vimeocdn.com'
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue