ok, took a break,
I could swear I tested this manually before writing all this, so back to some manual testing and here's what I learned
upnp-meta does not work with http addresses, it only works with local files
so this means a couple of things
1 no meta data = must play some video first otherwise video will play in the background
2 play script first calls upnp-meta = so can't use the play script
so for those that know what to do with it, here is a very early alpha version
press the stop button to start playback
default resolution is 240p,
valid options are 240p, 480p,720p
- Code: Select all
// Trailer Plugin WDTVExt plugin by KAD (2011)
//
//
/*
# meta-name="Trailer"
# meta-desc="WDTVExt Trailer"
# meta-author="KAD"
# meta-date="2012-02-02"
# meta-version="1.0.0"
# meta-type="wdtvext"
# meta-url="http://forum.wdlxtv.com"
# meta-filename="Trailer.plugin.js"
*/
traceln("Start loading Trailer Plugin");
function TrailerPlugin(path) {
this.rootPath = path;
this.debug = new Debug();
this.debug.Enable = true;
this.debug.Prefix = "Trailer:";
var dLevel = getConfigSetting("Trailer_DEBUG");
this.debug.Level = (dLevel === "") ? 0 : dLevel;
this.debug.Level = 5;
this.debug.Lib = (this.debug.Level > 2) ? this.debug.Level - 2 : 0;
this.coverShow = false;
this.debug.Log(" path: " + this.rootPath, 1);
this.SearchName = "SearchName";
this.SearchStream = "IMDBID";
this.trailerid = "TrailerID";
this.currentTrailer = "Trailer"
this.Format = getConfigSetting("TRAILER_RESOLUTION",this.debug.Lib);
var result1 = executeCmd("mount -o bind " + this.rootPath + "bin/play /usr/bin/play");
var result2 = executeCmd("mount -o bind " + this.rootPath + "bin/upnp-cmd /usr/bin/upnp-cmd");
var result3 = executeCmd("mount -o bind " + this.rootPath + "bin/upnp-meta /usr/bin/upnp-meta");
}
TrailerPlugin.prototype = new Plugin()
TrailerPlugin.prototype.constructor = TrailerPlugin;
TrailerPlugin.prototype.onPageKey = function(page, key) {
this.debug.Log("[onPageKey] page: " + page.markupFileName + " key: " + key, 2);
if (page.isMediaListPage) {
if ((page.markupFileName === "basic_browse.xml") ||
(page.markupFileName === "basic_browse_thumb_video.xml") ||
(page.markupFileName === "basic_browse_thumb.xml")) {
this.debug.Log("[ onPageKey ] (isMediaListPage) key: " + key, 1);
this.setSearchName(page);
if (key == 38 || key == 40)
this.selectionFix();
if (key == 41)
this.playTrailer();
}
}
}
TrailerPlugin.prototype.playTrailer = function() {
var Trailer = this.currentTrailer;
res1 = executeCmd("upnp-cmd SetAVTransportURI \"" + Trailer +"\"",2);
res2 = executeCmd("upnp-cmd Play", 3);
this.debug.Log(" playTrailer: " + Trailer, 3);
}
TrailerPlugin.prototype.selectionFix = function() {
this.debug.Log("[ selectionFix ]", 2);
system("oneDelaySelectionFix");
}
TrailerPlugin.prototype.setSearchName = function(page) {
this.debug.Log("[ setSearchName ]", 1);
Page.Top.setParam("SearchName", "");
var media = page.selectedMedia;
if (!media || media == "") {
return;
}
var SearchName = "";
if (media) {
if (media.path.lastIndexOf('/') === media.path.length-1) {
SearchName = (media.name);
this.debug.Log("[ setSearchName folder name]" + SearchName, 1);
Page.Top.setParam("SearchName", SearchName);
this.SearchName = SearchName;
this.debug.Log("[ setSearchName folder path]" + media.path, 1);
var metafile = (media.path + media.name + ".tgmd");
var NameSearchURL = ("http://app.imdb.com/find?q=" + SearchName);
this.debug.Log("[ getimdbid curl ]" + NameSearchURL, 2);
var curl = new CurlEasy(NameSearchURL);
if (curl.perform()) {
var content = eval("(" + curl.responseText + ")");
var result = content.data.results[0];
var lists = result.list[0];
var IMDBID = lists.tconst;
this.debug.Log("[ getimdbid IMDBID]" + IMDBID, 2);
}
this.SearchStream = IMDBID;
var SearchID = ("http://app.imdb.com/title/maindetails?tconst=" + IMDBID);
this.debug.Log("[ getstreamid curl ]" + SearchID, 2);
var curl2 = new CurlEasy(SearchID);
if (curl2.perform()) {
var content2 = eval("(" + curl2.responseText + ")");
var title = content2.data.title;
var TrailerID = content2.data.trailer.id;
this.debug.Log("[ getstreamid]" + TrailerID, 2);
}
this.trailerid = TrailerID;
} else {
file = (media.name);
SearchName = file.substr(0, file.lastIndexOf('.'));
this.debug.Log("[ setSearchName file name]" + SearchName, 1);
Page.Top.setParam("SearchName", SearchName);
this.SearchName = SearchName;
var metafile = (media.path + ".tgmd");
var NameSearchURL = ("http://app.imdb.com/find?q=" + SearchName);
this.debug.Log("[ getimdbid curl ]" + NameSearchURL, 2);
var curl = new CurlEasy(NameSearchURL);
if (curl.perform()) {
var content = eval("(" + curl.responseText + ")");
var result = content.data.results[0];
var lists = result.list[0];
var IMDBID = lists.tconst;
this.debug.Log("[ getimdbid IMDBID]" + IMDBID, 2);
this.SearchStream = IMDBID;
}
var SearchID = ("http://app.imdb.com/title/maindetails?tconst=" + IMDBID);
this.debug.Log("[ getstreamid curl ]" + SearchID, 2);
var curl2 = new CurlEasy(SearchID);
if (curl2.perform()) {
var content2 = eval("(" + curl2.responseText + ")");
var title = content2.data.title;
var TrailerID = content2.data.trailer.id;
this.debug.Log("[ getstreamid]" + TrailerID, 2);
}
this.trailerid = TrailerID;
}
}
if (this.Format == "") {
this.Format = "240p";
}
var URL = ("http://www.imdb.com/video/imdb/" + this.trailerid + "/html5?format=" + this.Format);
this.debug.Log("[ getstreamid]" + URL, 2);
this.URL = URL;
var curl3 = new CurlEasy(URL);
if (curl3.perform()) {
var StreamHTML = curl3.responseText;
StreamHTML.match(/mp4_h264\s+:\s+\'([^\']+)\'/);
var Trailer = RegExp.$1;
this.currentTrailer = Trailer;
this.debug.Log("[ getstreams]" + Trailer, 2);
}
}
TrailerPlugin.instance = new TrailerPlugin(scriptPath);
Plugin.registerPlugin(TrailerPlugin.instance);
traceln("End loading Trailer Plugin");
here's the rather large to do list
create on screen feedback on if trailer is available
create system for catching if get imdb ID fails,
- if fail, disable on screen feedback
- if successful update on screen feedback (I thinking icon, or text, possibly, include trailer name as well)
implement .tmgd or .nfo search and read
-idea would be to read the imdb ID # from existing .tmgd or .nfo
-and only if no present rely on name search
another idea for later versions, option to download trailer
write system checks for wrong trailers maybe match trailer name to file/folder name
and of coarse code clean up
KAD