You are going to download - You are going to download +
diff --git a/controllers/FrontController.php b/controllers/FrontController.php
index 233be8c..0a49450 100644
--- a/controllers/FrontController.php
+++ b/controllers/FrontController.php
@@ -209,7 +209,7 @@ class FrontController
private function getVideoResponse(Request $request, Response $response, array $params, $password = null)
{
try {
- $video = $this->download->getJSON($params['url'], $this->defaultFormat, $password);
+ $vidarr = $this->download->getJSON($params['url'], $this->defaultFormat, $password);
} catch (PasswordException $e) {
return $this->password($request, $response);
}
@@ -222,10 +222,10 @@ class FrontController
$response,
'video.tpl',
[
- 'video' => $video,
+ 'vidarr' => $vidarr,
'class' => 'video',
- 'title' => $video->title,
- 'description' => 'Download "'.$video->title.'" from '.$video->extractor_key,
+ 'title' => $vidarr[0]->title,
+ 'description' => 'Download "'.$vidarr[0]->title.'" from '.$vidarr[0]->extractor_key,
'protocol' => $protocol,
'config' => $this->config,
'canonical' => $this->getCanonicalUrl($request),
diff --git a/js/cast.js b/js/cast.js
index 0cc0bd3..bcadc01 100644
--- a/js/cast.js
+++ b/js/cast.js
@@ -2,7 +2,7 @@
/*jslint browser: true, nomen: true */
var castModule = (function () {
'use strict';
- var launchBtn, disabledBtn, stopBtn, session;
+ var launchBtn, disabledBtn, stopBtn, session, videoLink;
function receiverListener(e) {
return (e === chrome.cast.ReceiverAvailability.AVAILABLE);
@@ -51,7 +51,7 @@ var castModule = (function () {
function onRequestSessionSuccess(e) {
session = e;
- var videoLink = document.getElementById('video_link'), videoURL = videoLink.dataset.video, mediaInfo = new chrome.cast.media.MediaInfo(videoURL, 'video/' + videoLink.dataset.ext), request = new chrome.cast.media.LoadRequest(mediaInfo);
+ var videoURL = videoLink.dataset.video, mediaInfo = new chrome.cast.media.MediaInfo(videoURL, 'video/' + videoLink.dataset.ext), request = new chrome.cast.media.LoadRequest(mediaInfo);
session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError);
}
@@ -59,19 +59,23 @@ var castModule = (function () {
throw e.description;
}
- function launchCast() {
+ function launchCast(event) {
+ videoLink = event.target || event.srcElement;
chrome.cast.requestSession(onRequestSessionSuccess, onLaunchError);
}
function onInitSuccess() {
- 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);
+ launchBtn = document.getElementsByClassName('cast_btn_launch');
+ disabledBtn = document.getElementsByClassName('cast_disabled');
+ stopBtn = document.getElementsByClassName('cast_btn_stop');
+ if (launchBtn.length > 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);
+ }
}
}
@@ -94,11 +98,11 @@ var castModule = (function () {
return {
init: function () {
- var intro = document.getElementById('download_intro');
- if (intro) {
- intro.insertAdjacentHTML('beforeend', '
');
- window.__onGCastApiAvailable = loadCastApi;
+ var intro = document.getElementsByClassName('download_intro'), i;
+ for (i = 0; i < intro.length; i++) {
+ intro[i].insertAdjacentHTML('beforeend', '
');
}
+ window.__onGCastApiAvailable = loadCastApi;
}
};
}());
diff --git a/templates/video.tpl b/templates/video.tpl
index 8ee0c5f..1c3b73d 100644
--- a/templates/video.tpl
+++ b/templates/video.tpl
@@ -4,8 +4,9 @@
You are going to download - You are going to download +