

if (this.currentTrailer != "") {if (this.currentTrailer == "") {if (this.currentTrailer == "") {
this.debug.Log("[ test ]", 2);
} else {
this.PlayLocal = true;
return;
}
TrailerPlugin.prototype.setSearchName = function(page) {
this.debug.Log("[ setSearchName starting]", 1);
this.PlayLocal = false;
Page.Top.setParam("SearchName", "");
Page.Top.setParam("Trailer_Icon", "");
Page.Top.setParam("Trailer", "");
Page.Top.setParam("Title", "");
Page.Top.setParam("LocalTrailer", "");
var Trailer = "";
this.currentTrailer = Trailer;
var media = page.selectedMedia;
if (!media || media == "") {
return;
}
var SearchName = "";
if (media) {
if (this.Path != "") {
var Path = this.Path;
if (media.path.lastIndexOf('/') === media.path.length-1) {
var LocalTrailer = executeCmd("find '" + Path + "' -maxdepth 1 -name '." + media.name + "_Trailer.mp4'",this.debug.Lib);
var Trailer = LocalTrailer;
var Title = media.name;
this.Title = Title;
this.currentTrailer = Trailer;
if (this.currentTrailer != "") {
this.PlayLocal = true;
return;
}
} else {
var file = media.name;
var SearchName = file.substr(0, file.lastIndexOf('.'));
var LocalTrailer = executeCmd("find '" + Path + "' -maxdepth 1 -name '." + SearchName + "_Trailer.mp4'",this.debug.Lib);
var Trailer = LocalTrailer;
this.Title = SearchName;
this.currentTrailer = Trailer;
if (this.currentTrailer != "") {
this.PlayLocal = true;
return;
}
}
}
if (media.path.lastIndexOf('/') === media.path.length-1) {
var Path = (media.path);
this.CurrentPath = Path;
this.Name = media.name;
var LocalTrailer = executeCmd("find '" + media.path + "' -maxdepth 1 -name '." + media.name + "_Trailer.mp4'",this.debug.Lib);
var Trailer = LocalTrailer;
this.currentTrailer = Trailer;
if (this.currentTrailer != "") {
this.PlayLocal = true;
return;
}
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.CurrentPath = Path;
file = (media.name);
SearchName = file.substr(0, file.lastIndexOf('.'));
this.Name = Searchname;
var LocalTrailer = executeCmd("find '" + Path + "' -maxdepth 1 -name '." + SearchName + "_Trailer.mp4'",this.debug.Lib);
var Trailer = LocalTrailer;
this.currentTrailer = Trailer;
if (this.currentTrailer != "") {
this.PlayLocal = true;
return;
}
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);
}
}

KAD wrote:this line occurs 5 times in the entire script 4 in the section belowCode: Select allif (this.currentTrailer != "") {of the 5 occurances 2 are not working, both failures run the same line after working with filesthe other occurances are working with foldersand 1 occurance working, checks the value in a separate function and works regardless of folder or files selected


Lib: [executeCmd] cmd: find '/tmp/mnt/E8FA-9D51/Trailers/' -maxdepth 1 -name '.2012_Trailer.mp4'
Lib: [executeCmd] completed.
Trailer: [setTrailerICON]
Trailer: [setTrailerICON] disabled

dzebrys wrote:KAD wrote:this line occurs 5 times in the entire script 4 in the section belowCode: Select allif (this.currentTrailer != "") {of the 5 occurances 2 are not working, both failures run the same line after working with filesthe other occurances are working with foldersand 1 occurance working, checks the value in a separate function and works regardless of folder or files selected
in js for conditions you need to use !==, ===
br/piotr

TrailerPlugin.prototype.setSearchName = function(page) {
this.debug.Log("[ setSearchName starting]", 1);
this.PlayLocal = false;
Page.Top.setParam("SearchName", "");
Page.Top.setParam("Trailer_Icon", "");
Page.Top.setParam("Trailer", "");
Page.Top.setParam("Title", "");
Page.Top.setParam("LocalTrailer", "");
var Trailer = "";
this.currentTrailer = Trailer;
this.SearchStream = "";
var Name = "";
this.Name = Name;
Page.Top.setParam("LoadingScreen", "");
var media = page.selectedMedia;
if (!media || media == "") {
return;
}
var SearchName = "";
if (media) {
if (this.Path != "") {
var Path = this.Path;
if (media.path.lastIndexOf('/') === media.path.length-1) {
var LocalTrailer = executeCmd("find '" + Path + "/' -maxdepth 1 -name '." + media.name + "_Trailer.mp4'",this.debug.Lib);
var Trailer = LocalTrailer;
var Title = media.name;
this.Title = Title;
this.currentTrailer = Trailer;
if (this.currentTrailer != "") {
this.PlayLocal = true;
return;
}
var Name = media.name;
this.Name = Name;
var metafile = executeCmd("find '" + Path + "/' -maxdepth 1 -name '" + media.name + ".*.tgmd'",this.debug.Lib);
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);
Page.Top.setParam("Name", this.Name);
} else {
var file = media.name;
var SearchName = file.substr(0, file.lastIndexOf('.'));
var LocalTrailer = executeCmd("find '" + Path + "/' -maxdepth 1 -name '." + SearchName + "_Trailer.mp4'",this.debug.Lib);
var Trailer = LocalTrailer;
this.Title = SearchName;
this.currentTrailer = Trailer;
if (this.currentTrailer != "") {
this.PlayLocal = true;
return;
}
var Name = SearchName;
this.Name = Name;
var metafile = executeCmd("find '" + Path + "/' -maxdepth 1 -name '" + media.name + ".tgmd'",this.debug.Lib);
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);
Page.Top.setParam("Name", this.Name);
}
}
if (this.SearchStream == "") {
if (media.path.lastIndexOf('/') === media.path.length-1) {
this.CurrentPath = Path;
var Name = media.name;
this.Name = Name;
Page.Top.setParam("Name", this.Name);
var LocalTrailer = executeCmd("find '" + media.path + "' -maxdepth 1 -name '." + media.name + "_Trailer.mp4'",this.debug.Lib);
var Trailer = LocalTrailer;
this.currentTrailer = Trailer;
if (this.currentTrailer != "") {
this.PlayLocal = true;
return;
}
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.CurrentPath = Path;
file = (media.name);
SearchName = file.substr(0, file.lastIndexOf('.'));
var Name = Searchname;
this.Name = Searchname;
Page.Top.setParam("Name", this.Name);
var LocalTrailer = executeCmd("find '" + Path + "' -maxdepth 1 -name '." + SearchName + "_Trailer.mp4'",this.debug.Lib);
var Trailer = LocalTrailer;
this.currentTrailer = Trailer;
if (this.currentTrailer != "") {
this.PlayLocal = true;
return;
}
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);
}
}
}
}
}
}
if ( IMDBID == "" ) {
return;
}
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";
}
if (this.trailerid == "") {
return;
}
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);
}
}
} else {
var file = media.name;
var SearchName = file.substr(0, file.lastIndexOf('.'));
var LocalTrailer = executeCmd("find '" + Path + "/' -maxdepth 1 -name '." + SearchName + "_Trailer.mp4'",this.debug.Lib);
var Trailer = LocalTrailer;
this.Title = SearchName;
this.currentTrailer = Trailer;
if (this.currentTrailer != "") {
this.PlayLocal = true;
return;
}
var Name = SearchName;
this.Name = Name;
var metafile = executeCmd("find '" + Path + "/' -maxdepth 1 -name '" + media.name + ".tgmd'",this.debug.Lib);
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);
Page.Top.setParam("Name", this.Name);
}
this.SearchStream = IMDBID;var Name = SearchName;
this.Name = Name;
var metafile = executeCmd("find '" + Path + "/' -maxdepth 1 -name '" + media.name + ".tgmd'",this.debug.Lib);
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);
Page.Top.setParam("Name", this.Name);
this.SearchStream = IMDBID;
this.SearchStream = IMDBID[0];if (IMDBID.length > 0) {}

Users browsing this forum: No registered users and 1 guest