Permalink
Browse files

Add youtube support

  • Loading branch information...
1 parent a848a4d commit cf1ab2a51191cc4fd3474312e7b22f7547231d2e @NP- committed Feb 4, 2012
Showing with 32 additions and 16 deletions.
  1. +31 −15 hdtrailers.js
  2. +1 −1 plugin.json
View
@@ -1,8 +1,9 @@
/**
- * HD Trailers plugin for showtime version 0.11 by NP
+ * HD Trailers plugin for showtime version 0.12 by NP
*
* ChangeLog:
- * filter youtube links (not supported at the moment
+ * 0.12
+ * added support for youtube (requires youtube plugin)
* 0.11
* fix yahoo's link problem
*
@@ -36,13 +37,16 @@
var settings = plugin.createSettings("HD Trailers",
plugin.path + "logo.png",
- "HD Trailers");
+ "Movie Trailers");
settings.createInfo("info",
plugin.path + "logo.png",
- "HD-Trailers.net \nThis plugin was created for the sole purpose of allowing you to easily view HD (High Definition) movie trailers.\nBased on HD-Trailers.net"+
- "Plugin developed by NP \n");
+ "This plugin was created for the sole purpose of allowing you to easily view HD (High Definition) movie trailers.\nBased on HD-Trailers.net"+
+ "\nPlugin developed by NP");
+ settings.createBool("youtube", "Support Youtube links (requires youtube plugin)", false, function(v) {
+ service.youtube = v;
+ });
settings.createBool("hd", "HD", false, function(v) {
service.hd = v;
@@ -73,7 +77,7 @@
var trailers = new XML(showtime.httpGet("http://feeds.hd-trailers.net/hd-trailers").toString());
page.metadata.title = trailers.channel.lastBuildDate.toString() ;
var url = false;
-
+ var title = '';
for each (var item in trailers.channel.item) {
var metadata = {
@@ -90,8 +94,12 @@
else if (!url || url == '')
url = getValue(item.toString(), '"', '">480p&lt', 'endRef');
- if(url.indexOf('youtube.com')==-1)
- page.appendItem(url.replace(/amp;amp;/gi,''),"video", metadata);
+ if(url.indexOf('youtube.com')==-1){
+ page.appendItem(url.replace(/amp;amp;/gi,''),"video", metadata);
+ }else if(url.indexOf('clipconverter.cc')==-1 && service.youtube == "1"){
+ page.appendItem('youtube:video:simple:'+ metadata.title + ':' + getValue(url, 'v=', '&')
+ ,"video", metadata);
+ }
url = false;
}
@@ -150,12 +158,12 @@
var next = getValue(content, '"', '">Next &#8811', 'endRef');
content = getValue(content, '<table class="indexTable">', '</table>');
content = content.split('<td class="indexTableTrailerImage">');
- for each (var film in content)
- if(getValue(film, 'title="', '"') != '' &&
- getValue(film, 'href="','"').indexOf('youtube.com')==-1)
+ for each (var film in content){
+ if(getValue(film, 'title="', '"') != '')
page.appendItem( PREFIX + 'present:'+ getValue(film, 'href="','"'), "video",
{ title: getValue(film, 'title="', '"'),
icon: getValue(film, 'src="', '"')});
+ }
if(next != '')
page.appendItem( PREFIX + 'list:'+ next , "directory", { title: 'Next' });
@@ -174,17 +182,25 @@
content = getValue(content, '<table class="bottomTable">', '</table>');
content = content.split('<td class="bottomTableDate" rowspan="2">');
var url = '';
+ var title = '';
for each (var film in content){
if (service.fullhd == "1")
url = getValue(film, '"', '" rel="lightbox[res1080p', 'endRef');
else if (service.hd == "1")
url = getValue(film, '"', '" rel="lightbox[res720p', 'endRef');
else if (!url || url == '')
url = getValue(film, '"', '" rel="lightbox[res480p', 'endRef');
-
- if( url != '' && url.indexOf('youtube.com')==-1)
- page.appendItem(url.replace(/amp;amp;/gi,''), "video", { title: getValue(film, 'itemprop="name">', '<')});
- url = ''
+
+ title = getValue(film, 'itemprop="name">', '<');
+ if( url != '' && url.indexOf('youtube.com')==-1){
+ page.appendItem(url.replace(/amp;amp;/gi,''), "video", { title: title});
+ }else if( url != '' && url.indexOf('clipconverter.cc')==-1 && service.youtube == "1"){
+ showtime.trace('youtube: ' +url);
+ page.appendItem('youtube:video:simple:'+ title + ':' + getValue(url, 'v=', '&')
+ ,"video", { title: title});
+ }
+ url = '';
+ title = '';
}
page.loading = false;
View
@@ -1 +1 @@
-{"type": "javascript", "id": "hdtrailers", "file": "hdtrailers.js", "showtimeVersion": "3.1.188", "version": "0.11", "author": "NP", "title": "HD-Trailers", "icon": "logo.png", "synopsis": "Movie trailers", "description": "HD-Trailers.net \nThis plugin was created for the sole purpose of allowing you to easily view HD (High Definition) movie trailers.\nBased on HD-Trailers.net"}
+{"type": "javascript", "id": "hdtrailers", "file": "hdtrailers.js", "showtimeVersion": "3.1.188", "version": "0.12", "author": "NP", "title": "HD-Trailers", "icon": "logo.png", "synopsis": "Movie trailers", "description": "This plugin was created for the sole purpose of allowing you to easily view HD (High Definition) movie trailers.\nBased on <a href=\"http://www.hd-trailers.net\">HD-Trailers.net</a>", "homepage":"https://github.com/NP-/showtime-plugin-hdtrailers" }

0 comments on commit cf1ab2a

Please sign in to comment.