1
0
mirror of https://github.com/Rudloff/alltube.git synced 2024-06-26 07:29:06 +02:00

Merge branch 'feature/playlist' into develop

This commit is contained in:
Pierre Rudloff 2017-04-25 10:31:18 +02:00
commit 554dd14edd
7 changed files with 73 additions and 5 deletions

View File

@ -38,7 +38,7 @@ class Config
*
* @var array
*/
public $params = ['--no-playlist', '--no-warnings', '--playlist-end', 1];
public $params = ['--no-warnings'];
/**
* Enable audio conversion.

View File

@ -113,7 +113,7 @@ class VideoDownload
* */
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));
}
/**

View File

@ -222,9 +222,14 @@ class FrontController
} else {
$protocol = '[protocol^=http]';
}
if (isset($video->entries)) {
$template = 'playlist.tpl';
} else {
$template = 'video.tpl';
}
$this->view->render(
$response,
'video.tpl',
$template,
[
'video' => $video,
'class' => 'video',
@ -327,7 +332,11 @@ class FrontController
$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;
}

View File

@ -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
View 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"}

View File

@ -264,6 +264,22 @@ class FrontControllerTest extends \PHPUnit_Framework_TestCase
$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.
*

View File

@ -266,7 +266,6 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
$this->assertObjectHasAttribute('title', $info);
$this->assertObjectHasAttribute('extractor_key', $info);
$this->assertObjectHasAttribute('formats', $info);
$this->assertObjectHasAttribute('_filename', $info);
}
/**