Merge branch 'feature/playlist' into develop
This commit is contained in:
commit
554dd14edd
7 changed files with 73 additions and 5 deletions
|
@ -38,7 +38,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $params = ['--no-playlist', '--no-warnings', '--playlist-end', 1];
|
public $params = ['--no-warnings'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable audio conversion.
|
* Enable audio conversion.
|
||||||
|
|
|
@ -113,7 +113,7 @@ class VideoDownload
|
||||||
* */
|
* */
|
||||||
public function getJSON($url, $format = null, $password = null)
|
public function getJSON($url, $format = null, $password = null)
|
||||||
{
|
{
|
||||||
return json_decode($this->getProp($url, $format, 'dump-json', $password));
|
return json_decode($this->getProp($url, $format, 'dump-single-json', $password));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -222,9 +222,14 @@ class FrontController
|
||||||
} else {
|
} else {
|
||||||
$protocol = '[protocol^=http]';
|
$protocol = '[protocol^=http]';
|
||||||
}
|
}
|
||||||
|
if (isset($video->entries)) {
|
||||||
|
$template = 'playlist.tpl';
|
||||||
|
} else {
|
||||||
|
$template = 'video.tpl';
|
||||||
|
}
|
||||||
$this->view->render(
|
$this->view->render(
|
||||||
$response,
|
$response,
|
||||||
'video.tpl',
|
$template,
|
||||||
[
|
[
|
||||||
'video' => $video,
|
'video' => $video,
|
||||||
'class' => 'video',
|
'class' => 'video',
|
||||||
|
@ -327,7 +332,11 @@ class FrontController
|
||||||
$response = $response->withBody($stream->getBody());
|
$response = $response->withBody($stream->getBody());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$response = $response->withHeader('Content-Disposition', 'attachment; filename="'.$video->_filename.'"');
|
$response = $response->withHeader(
|
||||||
|
'Content-Disposition',
|
||||||
|
'attachment; filename="'.
|
||||||
|
$this->download->getFilename($url, $format, $password).'"'
|
||||||
|
);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -397,10 +397,34 @@ padding:3px;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Playlists */
|
||||||
|
.playlist-entry .thumb {
|
||||||
|
float: left;
|
||||||
|
margin-right: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.playlist-entry {
|
||||||
|
clear: both;
|
||||||
|
padding-top: 2em;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.playlist-entry h3 {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.playlist-entry h3 a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.playlist-entry h3 a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.playlist-entry .downloadBtn {
|
||||||
|
font-size: 16px;
|
||||||
|
border-width: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
20
templates/playlist.tpl
Normal file
20
templates/playlist.tpl
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{include file="inc/head.tpl"}
|
||||||
|
<div class="wrapper">
|
||||||
|
<div class="main">
|
||||||
|
{include file="inc/logo.tpl"}
|
||||||
|
<p>Videos extracted from the<i>
|
||||||
|
<a href="{$video->webpage_url}">
|
||||||
|
{$video->title}</a></i> playlist:
|
||||||
|
</p>
|
||||||
|
{foreach $video->entries as $video}
|
||||||
|
<div class="playlist-entry">
|
||||||
|
<img class="thumb" src="{$video->thumbnail}" alt="" width="200" />
|
||||||
|
<h3><a href="{$video->webpage_url}">{$video->title}</a></h3>
|
||||||
|
<a target="_blank" class="downloadBtn" href="{path_for name="redirect"}?url={$video->webpage_url}">Download</a>
|
||||||
|
<a target="_blank" href="{path_for name="video"}?url={$video->webpage_url}">More options</a>
|
||||||
|
</div>
|
||||||
|
{/foreach}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{include file="inc/footer.tpl"}
|
|
@ -264,6 +264,22 @@ class FrontControllerTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertTrue($result->isOk());
|
$this->assertTrue($result->isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the video() function with a playlist.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testVideoWithPlaylist()
|
||||||
|
{
|
||||||
|
$result = $this->controller->video(
|
||||||
|
$this->request->withQueryParams(
|
||||||
|
['url'=>'https://www.youtube.com/playlist?list=PLgdySZU6KUXL_8Jq5aUkyNV7wCa-4wZsC']
|
||||||
|
),
|
||||||
|
$this->response
|
||||||
|
);
|
||||||
|
$this->assertTrue($result->isOk());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the error() function.
|
* Test the error() function.
|
||||||
*
|
*
|
||||||
|
|
|
@ -266,7 +266,6 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertObjectHasAttribute('title', $info);
|
$this->assertObjectHasAttribute('title', $info);
|
||||||
$this->assertObjectHasAttribute('extractor_key', $info);
|
$this->assertObjectHasAttribute('extractor_key', $info);
|
||||||
$this->assertObjectHasAttribute('formats', $info);
|
$this->assertObjectHasAttribute('formats', $info);
|
||||||
$this->assertObjectHasAttribute('_filename', $info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue