refactor: Use route names that make more sense
This commit is contained in:
parent
660f322edd
commit
1df06f7c22
6 changed files with 117 additions and 98 deletions
|
@ -274,7 +274,7 @@ class FrontController
|
||||||
*
|
*
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
*/
|
*/
|
||||||
private function getVideoResponse(Request $request, Response $response)
|
private function getInfoResponse(Request $request, Response $response)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->video->getJson();
|
$this->video->getJson();
|
||||||
|
@ -285,7 +285,7 @@ class FrontController
|
||||||
if (isset($this->video->entries)) {
|
if (isset($this->video->entries)) {
|
||||||
$template = 'playlist.tpl';
|
$template = 'playlist.tpl';
|
||||||
} else {
|
} else {
|
||||||
$template = 'video.tpl';
|
$template = 'info.tpl';
|
||||||
}
|
}
|
||||||
$title = _('Video download');
|
$title = _('Video download');
|
||||||
$description = _('Download video from ').$this->video->extractor_key;
|
$description = _('Download video from ').$this->video->extractor_key;
|
||||||
|
@ -298,7 +298,7 @@ class FrontController
|
||||||
$template,
|
$template,
|
||||||
[
|
[
|
||||||
'video' => $this->video,
|
'video' => $this->video,
|
||||||
'class' => 'video',
|
'class' => 'info',
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'config' => $this->config,
|
'config' => $this->config,
|
||||||
|
@ -319,7 +319,7 @@ class FrontController
|
||||||
*
|
*
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
*/
|
*/
|
||||||
public function video(Request $request, Response $response)
|
public function info(Request $request, Response $response)
|
||||||
{
|
{
|
||||||
$url = $request->getQueryParam('url') ?: $request->getQueryParam('v');
|
$url = $request->getQueryParam('url') ?: $request->getQueryParam('v');
|
||||||
|
|
||||||
|
@ -332,9 +332,13 @@ class FrontController
|
||||||
$this->video = new Video($url, $this->defaultFormat, $password);
|
$this->video = new Video($url, $this->defaultFormat, $password);
|
||||||
|
|
||||||
if ($this->config->convert && $request->getQueryParam('audio')) {
|
if ($this->config->convert && $request->getQueryParam('audio')) {
|
||||||
return $this->getAudioResponse($request, $response);
|
// We skip the info page and get directly to the download.
|
||||||
|
return $response->withRedirect(
|
||||||
|
$this->container->get('router')->pathFor('download').
|
||||||
|
'?'.http_build_query($request->getQueryParams())
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return $this->getVideoResponse($request, $response);
|
return $this->getInfoResponse($request, $response);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return $response->withRedirect($this->container->get('router')->pathFor('index'));
|
return $response->withRedirect($this->container->get('router')->pathFor('index'));
|
||||||
|
@ -464,7 +468,7 @@ class FrontController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get approriate HTTP response to redirect query
|
* Get approriate HTTP response to download query.
|
||||||
* Depends on whether we want to stream, remux or simply redirect.
|
* Depends on whether we want to stream, remux or simply redirect.
|
||||||
*
|
*
|
||||||
* @param Response $response PSR-7 response
|
* @param Response $response PSR-7 response
|
||||||
|
@ -472,7 +476,7 @@ class FrontController
|
||||||
*
|
*
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
*/
|
*/
|
||||||
private function getRedirectResponse(Request $request, Response $response)
|
private function getDownloadResponse(Request $request, Response $response)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$videoUrls = $this->video->getUrl();
|
$videoUrls = $this->video->getUrl();
|
||||||
|
@ -532,7 +536,7 @@ class FrontController
|
||||||
*
|
*
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
*/
|
*/
|
||||||
public function redirect(Request $request, Response $response)
|
public function download(Request $request, Response $response)
|
||||||
{
|
{
|
||||||
$format = $this->getFormat($request);
|
$format = $this->getFormat($request);
|
||||||
$url = $request->getQueryParam('url');
|
$url = $request->getQueryParam('url');
|
||||||
|
@ -541,14 +545,19 @@ class FrontController
|
||||||
$this->video = new Video($url, $format, $this->sessionSegment->getFlash($url));
|
$this->video = new Video($url, $format, $this->sessionSegment->getFlash($url));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($this->config->convertAdvanced && !is_null($request->getQueryParam('customConvert'))) {
|
if ($this->config->convert && $request->getQueryParam('audio')) {
|
||||||
|
// Audio convert.
|
||||||
|
return $this->getAudioResponse($request, $response);
|
||||||
|
} elseif ($this->config->convertAdvanced && !is_null($request->getQueryParam('customConvert'))) {
|
||||||
|
// Advance convert.
|
||||||
return $this->getConvertedResponse($request, $response);
|
return $this->getConvertedResponse($request, $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getRedirectResponse($request, $response);
|
// Regular download.
|
||||||
|
return $this->getDownloadResponse($request, $response);
|
||||||
} catch (PasswordException $e) {
|
} catch (PasswordException $e) {
|
||||||
return $response->withRedirect(
|
return $response->withRedirect(
|
||||||
$this->container->get('router')->pathFor('video').'?url='.urlencode($url)
|
$this->container->get('router')->pathFor('info').'?url='.urlencode($url)
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$response->getBody()->write($e->getMessage());
|
$response->getBody()->write($e->getMessage());
|
||||||
|
|
22
index.php
22
index.php
|
@ -40,26 +40,36 @@ $app->get(
|
||||||
'/',
|
'/',
|
||||||
[$controller, 'index']
|
[$controller, 'index']
|
||||||
)->setName('index');
|
)->setName('index');
|
||||||
|
|
||||||
$app->get(
|
$app->get(
|
||||||
'/extractors',
|
'/extractors',
|
||||||
[$controller, 'extractors']
|
[$controller, 'extractors']
|
||||||
)->setName('extractors');
|
)->setName('extractors');
|
||||||
|
|
||||||
$app->any(
|
$app->any(
|
||||||
'/video',
|
'/info',
|
||||||
[$controller, 'video']
|
[$controller, 'info']
|
||||||
)->setName('video');
|
)->setName('info');
|
||||||
|
// Legacy route.
|
||||||
|
$app->any('/video', [$controller, 'info']);
|
||||||
|
|
||||||
$app->any(
|
$app->any(
|
||||||
'/watch',
|
'/watch',
|
||||||
[$controller, 'video']
|
[$controller, 'video']
|
||||||
);
|
);
|
||||||
|
|
||||||
$app->get(
|
$app->get(
|
||||||
'/redirect',
|
'/download',
|
||||||
[$controller, 'redirect']
|
[$controller, 'download']
|
||||||
)->setName('redirect');
|
)->setName('download');
|
||||||
|
// Legacy route.
|
||||||
|
$app->get('/redirect', [$controller, 'download']);
|
||||||
|
|
||||||
$app->get(
|
$app->get(
|
||||||
'/json',
|
'/json',
|
||||||
[$controller, 'json']
|
[$controller, 'json']
|
||||||
)->setName('json');
|
)->setName('json');
|
||||||
|
|
||||||
$app->get(
|
$app->get(
|
||||||
'/locale/{locale}',
|
'/locale/{locale}',
|
||||||
[$controller, 'locale']
|
[$controller, 'locale']
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<main class="main">
|
<main class="main">
|
||||||
<div><img class="logo" src="{base_url}/img/logo.png"
|
<div><img class="logo" src="{base_url}/img/logo.png"
|
||||||
alt="{$config->appName}" width="328" height="284"></div>
|
alt="{$config->appName}" width="328" height="284"></div>
|
||||||
<form action="{path_for name="video"}">
|
<form action="{path_for name="info"}">
|
||||||
<label class="labelurl" for="url">
|
<label class="labelurl" for="url">
|
||||||
{t}Copy here the URL of your video (Youtube, Dailymotion, etc.){/t}
|
{t}Copy here the URL of your video (Youtube, Dailymotion, etc.){/t}
|
||||||
</label>
|
</label>
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
required placeholder="http://example.com/video" />
|
required placeholder="http://example.com/video" />
|
||||||
</span>
|
</span>
|
||||||
{if $config->uglyUrls}
|
{if $config->uglyUrls}
|
||||||
<input type="hidden" name="page" value="video" />
|
<input type="hidden" name="page" value="info" />
|
||||||
{/if}
|
{/if}
|
||||||
<input class="downloadBtn large-font" type="submit" value="{t}Download{/t}" /><br/>
|
<input class="downloadBtn large-font" type="submit" value="{t}Download{/t}" /><br/>
|
||||||
{if $config->convert}
|
{if $config->convert}
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
<a class="combatiblelink small-font" href="{path_for name="extractors"}">{t}See all supported websites{/t}</a>
|
<a class="combatiblelink small-font" href="{path_for name="extractors"}">{t}See all supported websites{/t}</a>
|
||||||
<div id="bookmarklet" class="bookmarklet_wrapper">
|
<div id="bookmarklet" class="bookmarklet_wrapper">
|
||||||
<p> {t}Drag this to your bookmarks bar:{/t} </p>
|
<p> {t}Drag this to your bookmarks bar:{/t} </p>
|
||||||
<a class="bookmarklet small-font" href="javascript:window.location='{$domain}{path_for name='video'}?url='+encodeURIComponent(location.href);">{t}Bookmarklet{/t}</a>
|
<a class="bookmarklet small-font" href="javascript:window.location='{$domain}{path_for name='info'}?url='+encodeURIComponent(location.href);">{t}Bookmarklet{/t}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
<meta itemprop="uploadDate" content="{$video->upload_date}" />
|
<meta itemprop="uploadDate" content="{$video->upload_date}" />
|
||||||
{/if}
|
{/if}
|
||||||
<br/>
|
<br/>
|
||||||
<form action="{path_for name="redirect"}">
|
<form action="{path_for name="download"}">
|
||||||
<input type="hidden" name="url" value="{$video->webpage_url}" />
|
<input type="hidden" name="url" value="{$video->webpage_url}" />
|
||||||
{if isset($video->formats)}
|
{if isset($video->formats)}
|
||||||
<h3><label for="format">{t}Available formats:{/t}</label></h3>
|
<h3><label for="format">{t}Available formats:{/t}</label></h3>
|
||||||
{if $config->uglyUrls}
|
{if $config->uglyUrls}
|
||||||
<input type="hidden" name="page" value="redirect" />
|
<input type="hidden" name="page" value="download" />
|
||||||
{/if}
|
{/if}
|
||||||
<select name="format" id="format" class="formats monospace">
|
<select name="format" id="format" class="formats monospace">
|
||||||
<optgroup label="{t}Generic formats{/t}">
|
<optgroup label="{t}Generic formats{/t}">
|
|
@ -7,7 +7,7 @@
|
||||||
{$video->title}</a></i>{/if}{t}:{/t}
|
{$video->title}</a></i>{/if}{t}:{/t}
|
||||||
</p>
|
</p>
|
||||||
{if $config->stream}
|
{if $config->stream}
|
||||||
<a href="{path_for name="redirect"}?url={$video->webpage_url}" class="downloadBtn">Download everything</a>
|
<a href="{path_for name="download"}?url={$video->webpage_url}" class="downloadBtn">Download everything</a>
|
||||||
{/if}
|
{/if}
|
||||||
{foreach $video->entries as $entry}
|
{foreach $video->entries as $entry}
|
||||||
<div class="playlist-entry">
|
<div class="playlist-entry">
|
||||||
|
@ -27,8 +27,8 @@
|
||||||
{$entry->title}
|
{$entry->title}
|
||||||
{/if}
|
{/if}
|
||||||
</a></h3>
|
</a></h3>
|
||||||
<a target="_blank" class="downloadBtn" href="{path_for name="redirect"}?url={$entry->url}">{t}Download{/t}</a>
|
<a target="_blank" class="downloadBtn" href="{path_for name="download"}?url={$entry->url}">{t}Download{/t}</a>
|
||||||
<a target="_blank" href="{path_for name="video"}?url={$entry->url}">{t}More options{/t}</a>
|
<a target="_blank" href="{path_for name="info"}?url={$entry->url}">{t}More options{/t}</a>
|
||||||
</div>
|
</div>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
|
|
|
@ -65,12 +65,12 @@ class FrontControllerTest extends BaseTest
|
||||||
|
|
||||||
$this->container['router']->map(['GET'], '/', [$this->controller, 'index'])
|
$this->container['router']->map(['GET'], '/', [$this->controller, 'index'])
|
||||||
->setName('index');
|
->setName('index');
|
||||||
$this->container['router']->map(['GET'], '/video', [$this->controller, 'video'])
|
$this->container['router']->map(['GET'], '/video', [$this->controller, 'info'])
|
||||||
->setName('video');
|
->setName('info');
|
||||||
$this->container['router']->map(['GET'], '/extractors', [$this->controller, 'extractors'])
|
$this->container['router']->map(['GET'], '/extractors', [$this->controller, 'extractors'])
|
||||||
->setName('extractors');
|
->setName('extractors');
|
||||||
$this->container['router']->map(['GET'], '/redirect', [$this->controller, 'redirect'])
|
$this->container['router']->map(['GET'], '/redirect', [$this->controller, 'download'])
|
||||||
->setName('redirect');
|
->setName('download');
|
||||||
$this->container['router']->map(['GET'], '/locale', [$this->controller, 'locale'])
|
$this->container['router']->map(['GET'], '/locale', [$this->controller, 'locale'])
|
||||||
->setName('locale');
|
->setName('locale');
|
||||||
}
|
}
|
||||||
|
@ -211,43 +211,43 @@ class FrontControllerTest extends BaseTest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the video() function without the url parameter.
|
* Test the info() function without the url parameter.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testVideoWithoutUrl()
|
public function testInfoWithoutUrl()
|
||||||
{
|
{
|
||||||
$this->assertRequestIsRedirect('video');
|
$this->assertRequestIsRedirect('info');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the video() function.
|
* Test the info() function.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testVideo()
|
public function testInfo()
|
||||||
{
|
{
|
||||||
$this->assertRequestIsOk('video', ['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU']);
|
$this->assertRequestIsOk('info', ['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the video() function with audio conversion.
|
* Test the info() function with audio conversion.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testVideoWithAudio()
|
public function testInfoWithAudio()
|
||||||
{
|
{
|
||||||
Config::setOptions(['convert' => true]);
|
Config::setOptions(['convert' => true]);
|
||||||
|
|
||||||
$this->assertRequestIsOk('video', ['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'audio' => true]);
|
$this->assertRequestIsRedirect('info', ['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'audio' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the video() function with audio conversion from a Vimeo video.
|
* Test the info() function with audio conversion from a Vimeo video.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testVideoWithVimeoAudio()
|
public function testInfoWithVimeoAudio()
|
||||||
{
|
{
|
||||||
if (getenv('CI')) {
|
if (getenv('CI')) {
|
||||||
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
||||||
|
@ -255,20 +255,20 @@ class FrontControllerTest extends BaseTest
|
||||||
Config::setOptions(['convert' => true]);
|
Config::setOptions(['convert' => true]);
|
||||||
|
|
||||||
// So we can test the fallback to default format
|
// So we can test the fallback to default format
|
||||||
$this->assertRequestIsOk('video', ['url' => 'https://vimeo.com/251997032', 'audio' => true]);
|
$this->assertRequestIsRedirect('info', ['url' => 'https://vimeo.com/251997032', 'audio' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the video() function with audio enabled and an URL that doesn't need to be converted.
|
* Test the info() function with audio enabled and an URL that doesn't need to be converted.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testVideoWithUnconvertedAudio()
|
public function testInfoWithUnconvertedAudio()
|
||||||
{
|
{
|
||||||
Config::setOptions(['convert' => true]);
|
Config::setOptions(['convert' => true]);
|
||||||
|
|
||||||
$this->assertRequestIsRedirect(
|
$this->assertRequestIsRedirect(
|
||||||
'video',
|
'info',
|
||||||
[
|
[
|
||||||
'url' => 'https://2080.bandcamp.com/track/cygnus-x-the-orange-theme-2080-faulty-chip-cover',
|
'url' => 'https://2080.bandcamp.com/track/cygnus-x-the-orange-theme-2080-faulty-chip-cover',
|
||||||
'audio' => true,
|
'audio' => true,
|
||||||
|
@ -277,16 +277,16 @@ class FrontControllerTest extends BaseTest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the video() function with a password.
|
* Test the info() function with a password.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testVideoWithPassword()
|
public function testInfoWithPassword()
|
||||||
{
|
{
|
||||||
if (getenv('CI')) {
|
if (getenv('CI')) {
|
||||||
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
||||||
}
|
}
|
||||||
$result = $this->controller->video(
|
$result = $this->controller->info(
|
||||||
$this->request->withQueryParams(['url' => 'http://vimeo.com/68375962'])
|
$this->request->withQueryParams(['url' => 'http://vimeo.com/68375962'])
|
||||||
->withParsedBody(['password' => 'youtube-dl']),
|
->withParsedBody(['password' => 'youtube-dl']),
|
||||||
$this->response
|
$this->response
|
||||||
|
@ -295,44 +295,44 @@ class FrontControllerTest extends BaseTest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the video() function with a missing password.
|
* Test the info() function with a missing password.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testVideoWithMissingPassword()
|
public function testInfoWithMissingPassword()
|
||||||
{
|
{
|
||||||
if (getenv('CI')) {
|
if (getenv('CI')) {
|
||||||
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
||||||
}
|
}
|
||||||
$this->assertRequestIsOk('video', ['url' => 'http://vimeo.com/68375962']);
|
$this->assertRequestIsOk('info', ['url' => 'http://vimeo.com/68375962']);
|
||||||
$this->assertRequestIsOk('video', ['url' => 'http://vimeo.com/68375962', 'audio' => true]);
|
$this->assertRequestIsOk('info', ['url' => 'http://vimeo.com/68375962', 'audio' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the video() function with streams enabled.
|
* Test the info() function with streams enabled.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testVideoWithStream()
|
public function testInfoWithStream()
|
||||||
{
|
{
|
||||||
Config::setOptions(['stream' => true]);
|
Config::setOptions(['stream' => true]);
|
||||||
|
|
||||||
$this->assertRequestIsOk('video', ['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU']);
|
$this->assertRequestIsOk('info', ['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU']);
|
||||||
$this->assertRequestIsOk(
|
$this->assertRequestIsOk(
|
||||||
'video',
|
'info',
|
||||||
['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'audio' => true]
|
['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'audio' => true]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the video() function with a playlist.
|
* Test the info() function with a playlist.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testVideoWithPlaylist()
|
public function testInfoWithPlaylist()
|
||||||
{
|
{
|
||||||
$this->assertRequestIsOk(
|
$this->assertRequestIsOk(
|
||||||
'video',
|
'info',
|
||||||
['url' => 'https://www.youtube.com/playlist?list=PLgdySZU6KUXL_8Jq5aUkyNV7wCa-4wZsC']
|
['url' => 'https://www.youtube.com/playlist?list=PLgdySZU6KUXL_8Jq5aUkyNV7wCa-4wZsC']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -349,59 +349,59 @@ class FrontControllerTest extends BaseTest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function without the URL parameter.
|
* Test the download() function without the URL parameter.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithoutUrl()
|
public function testDownloadWithoutUrl()
|
||||||
{
|
{
|
||||||
$this->assertRequestIsRedirect('redirect');
|
$this->assertRequestIsRedirect('download');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function.
|
* Test the download() function.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirect()
|
public function testDownload()
|
||||||
{
|
{
|
||||||
$this->assertRequestIsRedirect('redirect', ['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU']);
|
$this->assertRequestIsRedirect('download', ['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function with a specific format.
|
* Test the download() function with a specific format.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithFormat()
|
public function testDownloadWithFormat()
|
||||||
{
|
{
|
||||||
$this->assertRequestIsRedirect(
|
$this->assertRequestIsRedirect(
|
||||||
'redirect',
|
'download',
|
||||||
['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'format' => 'worst']
|
['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'format' => 'worst']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function with streams enabled.
|
* Test the download() function with streams enabled.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithStream()
|
public function testDownloadWithStream()
|
||||||
{
|
{
|
||||||
Config::setOptions(['stream' => true]);
|
Config::setOptions(['stream' => true]);
|
||||||
|
|
||||||
$this->assertRequestIsOk(
|
$this->assertRequestIsOk(
|
||||||
'redirect',
|
'download',
|
||||||
['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU']
|
['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function with an M3U stream.
|
* Test the download() function with an M3U stream.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithM3uStream()
|
public function testDownloadWithM3uStream()
|
||||||
{
|
{
|
||||||
if (getenv('CI')) {
|
if (getenv('CI')) {
|
||||||
$this->markTestSkipped('Twitter returns a 429 error when the test is ran too many times.');
|
$this->markTestSkipped('Twitter returns a 429 error when the test is ran too many times.');
|
||||||
|
@ -410,7 +410,7 @@ class FrontControllerTest extends BaseTest
|
||||||
Config::setOptions(['stream' => true]);
|
Config::setOptions(['stream' => true]);
|
||||||
|
|
||||||
$this->assertRequestIsOk(
|
$this->assertRequestIsOk(
|
||||||
'redirect',
|
'download',
|
||||||
[
|
[
|
||||||
'url' => 'https://twitter.com/verge/status/813055465324056576/video/1',
|
'url' => 'https://twitter.com/verge/status/813055465324056576/video/1',
|
||||||
'format' => 'hls-2176',
|
'format' => 'hls-2176',
|
||||||
|
@ -419,33 +419,33 @@ class FrontControllerTest extends BaseTest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function with an RTMP stream.
|
* Test the download() function with an RTMP stream.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithRtmpStream()
|
public function testDownloadWithRtmpStream()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('We need to find another RTMP video.');
|
$this->markTestIncomplete('We need to find another RTMP video.');
|
||||||
|
|
||||||
Config::setOptions(['stream' => true]);
|
Config::setOptions(['stream' => true]);
|
||||||
|
|
||||||
$this->assertRequestIsOk(
|
$this->assertRequestIsOk(
|
||||||
'redirect',
|
'download',
|
||||||
['url' => 'http://www.rtvnh.nl/video/131946', 'format' => 'rtmp-264']
|
['url' => 'http://www.rtvnh.nl/video/131946', 'format' => 'rtmp-264']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function with a remuxed video.
|
* Test the download() function with a remuxed video.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithRemux()
|
public function testDownloadWithRemux()
|
||||||
{
|
{
|
||||||
Config::setOptions(['remux' => true]);
|
Config::setOptions(['remux' => true]);
|
||||||
|
|
||||||
$this->assertRequestIsOk(
|
$this->assertRequestIsOk(
|
||||||
'redirect',
|
'download',
|
||||||
[
|
[
|
||||||
'url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU',
|
'url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU',
|
||||||
'format' => 'bestvideo+bestaudio',
|
'format' => 'bestvideo+bestaudio',
|
||||||
|
@ -454,14 +454,14 @@ class FrontControllerTest extends BaseTest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function with a remuxed video but remux disabled.
|
* Test the download() function with a remuxed video but remux disabled.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithRemuxDisabled()
|
public function testDownloadWithRemuxDisabled()
|
||||||
{
|
{
|
||||||
$this->assertRequestIsServerError(
|
$this->assertRequestIsServerError(
|
||||||
'redirect',
|
'download',
|
||||||
[
|
[
|
||||||
'url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU',
|
'url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU',
|
||||||
'format' => 'bestvideo+bestaudio',
|
'format' => 'bestvideo+bestaudio',
|
||||||
|
@ -470,69 +470,69 @@ class FrontControllerTest extends BaseTest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function with a missing password.
|
* Test the download() function with a missing password.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithMissingPassword()
|
public function testDownloadWithMissingPassword()
|
||||||
{
|
{
|
||||||
if (getenv('CI')) {
|
if (getenv('CI')) {
|
||||||
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
|
||||||
}
|
}
|
||||||
$this->assertRequestIsRedirect('redirect', ['url' => 'http://vimeo.com/68375962']);
|
$this->assertRequestIsRedirect('download', ['url' => 'http://vimeo.com/68375962']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function with an error.
|
* Test the download() function with an error.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithError()
|
public function testDownloadWithError()
|
||||||
{
|
{
|
||||||
$this->assertRequestIsServerError('redirect', ['url' => 'http://example.com/foo']);
|
$this->assertRequestIsServerError('download', ['url' => 'http://example.com/foo']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function with an video that returns an empty URL.
|
* Test the download() function with an video that returns an empty URL.
|
||||||
* This can be caused by trying to redirect to a playlist.
|
* This can be caused by trying to redirect to a playlist.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithEmptyUrl()
|
public function testDownloadWithEmptyUrl()
|
||||||
{
|
{
|
||||||
$this->assertRequestIsServerError(
|
$this->assertRequestIsServerError(
|
||||||
'redirect',
|
'download',
|
||||||
['url' => 'https://www.youtube.com/playlist?list=PLgdySZU6KUXL_8Jq5aUkyNV7wCa-4wZsC']
|
['url' => 'https://www.youtube.com/playlist?list=PLgdySZU6KUXL_8Jq5aUkyNV7wCa-4wZsC']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function with a playlist stream.
|
* Test the download() function with a playlist stream.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @requires OS Linux
|
* @requires OS Linux
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithPlaylist()
|
public function testDownloadWithPlaylist()
|
||||||
{
|
{
|
||||||
Config::setOptions(['stream' => true]);
|
Config::setOptions(['stream' => true]);
|
||||||
|
|
||||||
$this->assertRequestIsOk(
|
$this->assertRequestIsOk(
|
||||||
'redirect',
|
'download',
|
||||||
['url' => 'https://www.youtube.com/playlist?list=PLgdySZU6KUXL_8Jq5aUkyNV7wCa-4wZsC']
|
['url' => 'https://www.youtube.com/playlist?list=PLgdySZU6KUXL_8Jq5aUkyNV7wCa-4wZsC']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the redirect() function with an advanced conversion.
|
* Test the download() function with an advanced conversion.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRedirectWithAdvancedConversion()
|
public function testDownloadWithAdvancedConversion()
|
||||||
{
|
{
|
||||||
Config::setOptions(['convertAdvanced' => true]);
|
Config::setOptions(['convertAdvanced' => true]);
|
||||||
|
|
||||||
$this->assertRequestIsOk(
|
$this->assertRequestIsOk(
|
||||||
'redirect',
|
'download',
|
||||||
[
|
[
|
||||||
'url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU',
|
'url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU',
|
||||||
'format' => 'best',
|
'format' => 'best',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue