Videos extracted from the + +{$video->title} playlist: +
+{foreach $video->entries as $video} + +{/foreach} + +diff --git a/classes/Config.php b/classes/Config.php
index 4ee07c1..b90a6ca 100644
--- a/classes/Config.php
+++ b/classes/Config.php
@@ -38,7 +38,7 @@ class Config
*
* @var array
*/
- public $params = ['--no-playlist', '--no-warnings', '--playlist-end', 1];
+ public $params = ['--no-warnings'];
/**
* Enable audio conversion.
diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php
index f773d2c..a838303 100644
--- a/classes/VideoDownload.php
+++ b/classes/VideoDownload.php
@@ -113,14 +113,7 @@ class VideoDownload
* */
public function getJSON($url, $format = null, $password = null)
{
- $jsonArray = preg_split( "/\r|\n/", $this->getProp($url, $format, 'dump-json', $password), -1,
- PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
- $decodedJson = array();
- foreach ($jsonArray as $oneJson)
- {
- array_push($decodedJson, json_decode($oneJson));
- }
- return $decodedJson;
+ return json_decode($this->getProp($url, $format, 'dump-single-json', $password));
}
/**
diff --git a/controllers/FrontController.php b/controllers/FrontController.php
index 4fb6548..83b2db8 100644
--- a/controllers/FrontController.php
+++ b/controllers/FrontController.php
@@ -213,7 +213,7 @@ class FrontController
private function getVideoResponse(Request $request, Response $response, array $params, $password = null)
{
try {
- $vidarr = $this->download->getJSON($params['url'], $this->defaultFormat, $password);
+ $video = $this->download->getJSON($params['url'], $this->defaultFormat, $password);
} catch (PasswordException $e) {
return $this->password($request, $response);
}
@@ -222,14 +222,19 @@ class FrontController
} else {
$protocol = '[protocol^=http]';
}
+ if (isset($video->entries)) {
+ $template = 'playlist.tpl';
+ } else {
+ $template = 'video.tpl';
+ }
$this->view->render(
$response,
- 'video.tpl',
+ $template,
[
- 'vidarr' => $vidarr,
+ 'video' => $video,
'class' => 'video',
- 'title' => $vidarr[0]->title,
- 'description' => 'Download "'.$vidarr[0]->title.'" from '.$vidarr[0]->extractor_key,
+ 'title' => $video->title,
+ 'description' => 'Download "'.$video->title.'" from '.$video->extractor_key,
'protocol' => $protocol,
'config' => $this->config,
'canonical' => $this->getCanonicalUrl($request),
@@ -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;
}
diff --git a/css/style.css b/css/style.css
index 31ae741..4ec7276 100644
--- a/css/style.css
+++ b/css/style.css
@@ -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;
+}
diff --git a/index.php b/index.php
index ce07549..b3b77de 100644
--- a/index.php
+++ b/index.php
@@ -1,4 +1,5 @@
0) {
- var i;
- for (i = 0; i < launchBtn.length; i++) {
- disabledBtn[i].classList.add('cast_hidden');
- launchBtn[i].classList.remove('cast_hidden');
- launchBtn[i].addEventListener('click', launchCast, false);
- stopBtn[i].addEventListener('click', stopCast, false);
- }
+ launchBtn = document.getElementById('cast_btn_launch');
+ disabledBtn = document.getElementById('cast_disabled');
+ stopBtn = document.getElementById('cast_btn_stop');
+ if (launchBtn) {
+ disabledBtn.classList.add('cast_hidden');
+ launchBtn.classList.remove('cast_hidden');
+ launchBtn.addEventListener('click', launchCast, false);
+ stopBtn.addEventListener('click', stopCast, false);
}
}
@@ -98,11 +94,11 @@ var castModule = (function () {
return {
init: function () {
- var intro = document.getElementsByClassName('download_intro'), i;
- for (i = 0; i < intro.length; i++) {
- intro[i].insertAdjacentHTML('beforeend', '
');
+ var intro = document.getElementById('download_intro');
+ if (intro) {
+ intro.insertAdjacentHTML('beforeend', '
');
+ window.__onGCastApiAvailable = loadCastApi;
}
- window.__onGCastApiAvailable = loadCastApi;
}
};
}());
diff --git a/templates/playlist.tpl b/templates/playlist.tpl
new file mode 100644
index 0000000..c62ec59
--- /dev/null
+++ b/templates/playlist.tpl
@@ -0,0 +1,19 @@
+{include file="inc/head.tpl"}
+
Videos extracted from the + +{$video->title} playlist: +
+{foreach $video->entries as $video} + +{/foreach} + +You are going to download - - {$video->title}. -
- {if isset($video->thumbnail)} -