so do you guys ever get tired of answering my questions
I've got a couple of them tonight
1.
I'm trying to get an additional image to show up and just can't seem to do it
the idea is after initiating playback sometimes you wait 5 or 10 seconds for playback to begin, sitting wondering if anything is going to happen
the image would be an indication the the trailer is being loadedStill some additional onpagecreated items to do, but the above image listed is done
2. any idea how to ensure this does not run when browsing photo's or music
on the + side, I found out this works inside network shares as well
edit: I guess maybe an on menuselect to disable/enable
select video - enable
select music or photo - disable Solved
3.
once the above is fixed, I'll look at a download option, you'll see I have a few lines in the code already, but they are more like notes at this point, but if you've got any feedback on it download works but still needs some polish
besides that 25 downloads on that functional beta with no complaints, I guess that means it was actually working better than I originally thought
here's the code as it sits
there's been a lot of fixes
- Code: Select all
// Trailer Plugin WDTVExt plugin by KAD (2012)
//
//
/*
# meta-name="Trailer"
# meta-desc="WDTVExt Trailer"
# meta-author="KAD"
# meta-date="2012-02-12"
# 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.Lib);
this.debug.Level = (dLevel === "") ? 0 : dLevel;
this.debug.Level = 5;
this.debug.Lib = (this.debug.Level > 2) ? this.debug.Level - 2 : 0;
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);
this.Path = getConfigSetting("TRAILER_DOWNLOAD_PATH",this.debug.Lib);
this.showICON = "Icon";
this.Title = "Title";
var LoadingScreen = ( this.rootPath + "osd/Loading.jpg" );
this.LoadingScreen = "LoadingScreen";
this.TrailerIcon = "Trailer_Icon";
this.NowLoading = false;
result1 = executeCmd("ln -s " + this.rootPath + "var/www/addons/config/plugins/TRAILER_wec.php /tmp/config-plugins/TRAILER_wec.php");
}
TrailerPlugin.prototype = new Plugin()
TrailerPlugin.prototype.constructor = TrailerPlugin;
TrailerPlugin.prototype.onPageCreated = function(page) {
this.debug.Log("[ onPageCreated ]")
if ((page.markupFileName === "basic_browse.xml") ||
(page.markupFileName === "basic_browse_thumb_video.xml") ||
(page.markupFileName === "basic_browse_thumb.xml")) {
if (this.NowLoading === false) {
if (!page.extraContent) {
page.extraContent = ""
}
var extraContent = <wrapper disable="@@my_Trailer_Icon_disable">
<image image="@@Trailer_Icon" x="40" y="40" w="200" h="250" scale="100" bg="0" disable="@@my_Trailer_Icon_disable" />
</wrapper>;
}
if (this.NowLoading === true) {
var extraContent = <wrapper disable="@@Loading_Icon_disable">
<image image="@@LoadingScreen" x="0" y="0" w="1280" h="720" bg="0" disable="@@Loading_Icon_disable" />
</wrapper>;
}
addExtraContent(page, extraContent, this.LibDebug)
this.debug.Log("[onPageCreated] added extra content.", 2);
}
}
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);
this.setTrailerICON(page);
if (key == 53)
this.playTrailer();
if (key == 64 || key == 32 || key == 33 || key ==29 || key == 28)
this.selectionFix(page);
}
}
}
TrailerPlugin.prototype.onPageEnter = function (page) {
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("[ onPageEnter ] (isMediaListPage) page: " + page.markupFileName,1);
this.selectionFix(page);
}
}
}
TrailerPlugin.prototype.selectionFix = function() {
this.debug.Log("[ selectionFix ]", 2);
system("oneDelaySelectionFix");
}
TrailerPlugin.prototype.onPageLeave = function(page) {
this.debug.Log("[onPageLeave] page: " + page.markupFileName, 3);
if (page.markupFileName === "video_ex_playing.xml") {
Page.Top.setParam("Loading_Icon_disable", "1")
this.NowLoading = false;
}
}
TrailerPlugin.prototype.TrailerDownload = function() {
this.debug.Log("[ TrailerDownload]: ", 3);
if ( this.Path == "" ) {
var Path = (Path);
} else {
var Path = this.Path;
}
Download = executeCmd("wget -O -P" + Path + "\"" + Trailer + " --output-document=" + Title + "_Trailer.mp4");
}
TrailerPlugin.prototype.setTrailerICON = function(page) {
this.debug.Log("[setTrailerICON] ", 2);
var Trailer_Icon = (this.rootPath + "osd/icon.png");
this.TrailerIcon = Trailer_Icon;
if (this.currentTrailer != "") {
Page.Top.setParam("Trailer_Icon", this.TrailerIcon);
Page.Top.setParam("my_Trailer_Icon_disable", "0")
this.debug.Log("[setTrailerICON] enabled " + this.TrailerIcon,1);
} else {
Page.Top.setParam("Trailer_Icon", "");
Page.Top.setParam("my_Trailer_Icon_disable", "1")
this.debug.Log("[setTrailerICON] disabled",1);
}
}
TrailerPlugin.prototype.playTrailer = function() {
this.NowLoading = true;
Page.Top.setParam("LoadingScreen", this.LoadingScreen);
Page.Top.setParam("Loading_Icon_disable", "0")
Page.Top.redraw(true);
this.debug.Log("[setLoadingImage] enabled ",1);
var Trailer = this.currentTrailer;
var Title = this.Title;
var meta = ("<DIDL-Lite xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\"><item id=\"" + Trailer + "\" parentID=\"" + Trailer + "\" restricted=\"0\"><dc:title>" + Title + "</dc:title><dc:date></dc:date><upnp:class>object.item.imageItem</upnp:class><dc:creator></dc:creator><upnp:genre></upnp:genre><upnp:artist></upnp:artist><upnp:album></upnp:album><res protocolInfo=\"file-get:*:*::DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00000000001000000000000000000000\" protection=\"\" tokenType=\"0\" bitrate=\"0\" duration=\"\" size=\"\" colorDepth=\"0\" ifoFileURI=\"\" resolution=\"\">" + Trailer + "</res></item></DIDL-Lite>");
var meta1 = meta.replace(/&/g, "&");
res1 = executeCmd("upnp-cmd SetAVTransportURI \"" + Trailer + "\" " + "\'" + meta1 + "\'",2);
res2 = executeCmd("upnp-cmd Play", 3);
this.debug.Log(" playTrailer: " + Trailer, 3);
}
TrailerPlugin.prototype.setSearchName = function(page) {
this.debug.Log("[ setSearchName starting]", 1);
Page.Top.setParam("SearchName", "");
Page.Top.setParam("Trailer_Icon", "");
Page.Top.setParam("Trailer", "");
var Trailer = "";
this.currentTrailer = Trailer;
var media = page.selectedMedia;
if (!media || media == "") {
return;
}
var SearchName = "";
if (media) {
if (media.path.lastIndexOf('/') === media.path.length-1) {
var Path = (media.path);
this.debug.Log("[ metafile folder Path]" + Path, 1);
var metafile = executeCmd("find '" + media.path + "' -maxdepth 1 -name '" + media.name + ".*.tgmd'",this.debug.Lib);
this.debug.Log("[ metafile folder tgmd name]" + metafile, 1);
var IMDBID = executeCmd("sed -n -e 's/.*<id>\\(.*\\)<\\/id>.*/\\1/p' \"" + metafile + "\"",this.debug.Lib);
this.debug.Log("[ metafile folder tgmd ID]" + IMDBID, 1);
this.SearchStream = IMDBID;
Page.Top.setParam("IMDBID", this.SearchStream);
if (this.SearchStream == "") {
var metafile = executeCmd("find '" + media.path + "' -maxdepth 1 -name '" + "*.nfo'",this.debug.Lib);
this.debug.Log("[ metafile folder nfo name]" + metafile, 1);
var IMDBID = executeCmd("sed -n -e 's/.*<id>\\(.*\\)<\\/id>.*/\\1/p' \"" + metafile + "\"",this.debug.Lib);
this.debug.Log("[ metafile folder nfo ID]" + IMDBID, 1);
this.SearchStream = IMDBID;
Page.Top.setParam("IMDBID", this.SearchStream);
}
if (this.SearchStream == "") {
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 NameSearchURL = ("http://app.imdb.com/find?q=" + SearchName);
this.debug.Log("[ SearchName folder 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];
if ( lists.tconst == null ) {
var Trailer = "";
this.currentTrailer = Trailer;
return;
} else {
var IMDBID = lists.tconst;
this.debug.Log("[ SearchName folder IMDBID]" + IMDBID, 2);
this.SearchStream = IMDBID;
Page.Top.setParam("IMDBID", this.SearchStream);
}
}
}
} else {
MediaPath = (media.path);
var Path = MediaPath.substr(0, MediaPath.lastIndexOf('/'));
this.debug.Log("[ metafile file Path]" + Path, 1);
var metafile = (media.path + ".tgmd");
this.debug.Log("[ metafile file tgmd name]" + metafile, 1)
var IMDBID = executeCmd("sed -n -e 's/.*<id>\\(.*\\)<\\/id>.*/\\1/p' \"" + metafile + "\"",this.debug.Lib);
this.debug.Log("[ metafile file tgmd ID]" + IMDBID, 1);
this.SearchStream = IMDBID;
Page.Top.setParam("IMDBID", this.SearchStream);
if (this.SearchStream == "" ) {
var path = (media.path);
var nfo1 = path.substr(0, path.lastIndexOf('.'));
var metafile = (nfo1 + ".nfo");
this.debug.Log("[ metafile file nfo name]" + metafile, 1)
var IMDBID = executeCmd("sed -n -e 's/.*<id>\\(.*\\)<\\/id>.*/\\1/p' \"" + metafile + "\"",this.debug.Lib);
this.SearchStream = IMDBID;
Page.Top.setParam("IMDBID", this.SearchStream);
}
if (this.SearchStream == "" ) {
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 NameSearchURL = ("http://app.imdb.com/find?q=" + SearchName);
this.debug.Log("[ SearchName file curl ]" + NameSearchURL, 2);
var curl = new CurlEasy(NameSearchURL);
if (curl.perform()) {
var content = eval("(" + curl.responseText + ")");
var result = content.data.results[0];
this.debug.Log("[ SearchName folder IMDBID]" + result, 2);
var lists = result.list[0];
if ( lists.tconst == null ) {
var Trailer = "";
this.currentTrailer = Trailer;
return;
} else {
var IMDBID = lists.tconst;
this.debug.Log("[ SearchName file IMDBID]" + IMDBID, 2);
this.SearchStream = IMDBID;
Page.Top.setParam("IMDBID", this.SearchStream);
}
}
}
}
}
var SearchID = ("http://app.imdb.com/title/maindetails?tconst=" + IMDBID);
this.debug.Log("[ get video id curl ]" + SearchID, 2);
var curl2 = new CurlEasy(SearchID);
if (curl2.perform()) {
var content2 = eval("(" + curl2.responseText + ")");
var Title = content2.data.title;
this.Title = Title;
Page.Top.setParam("Title", this.Title);
if ( content2.data.trailer == null ) {
var Trailer = "";
this.currentTrailer = Trailer;
return;
} else {
var TrailerID = content2.data.trailer.id;
this.debug.Log("[ get video id] " + TrailerID, 2);
}
}
this.trailerid = TrailerID;
Page.Top.setParam("TrailerID", this.trailerid);
if (this.Format == "") {
this.Format = "240p";
}
var URL = ("http://www.imdb.com/video/imdb/" + this.trailerid + "/html5?format=" + this.Format);
this.debug.Log("[ get real URL ]" + 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("[ Real URL ]" + Trailer, 2);
}
}
TrailerPlugin.instance = new TrailerPlugin(scriptPath);
Plugin.registerPlugin(TrailerPlugin.instance);
traceln("End loading Trailer Plugin");