Hey there,
PlexConnect is great and i love it. But i'm a bit unhappy with the trailer function an tmdb. A lot of movie trailer are not found on tmdb and that would be found are in english. I want trailers in german. So, now im learning a bit python and thought, try to rebuild the trailer function. Well, i found out all the trailer code is in javascript :P
Now i've rewritten the trailers.js, that it search and get trailers directly from youtube, possibly in any language, but the lange is "hardcoded" in the url string yet.
/*
* lookup movie title on tmdb and pass trailer ID to PlexConnect
*/
function playTrailer(title,year)
{
var google_api_key = "PutGoogleApiKeyHere";
var lookup = "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&order=relevance&key="+google_api_key+"&q="+encodeURIComponent(title+" "+year+" trailer deutsch");
var req = new XMLHttpRequest();
req.open('GET', lookup, false);
req.send();
var doc = JSON.parse(req.responseText);
if (doc.items[0].id.videoId.length === 0)
{
XML_Error("{{TEXT(PlexConnect)}}", "{{TEXT(Youtube: Kein Trailer gefunden)}}");
return;
}
var id = doc.items[0].id.videoId;
var url = "{{URL(/)}}&PlexConnect=PlayTrailer&PlexConnectTrailerID="+id;
atv.loadURL(url);
};
/*
- displays error message
*/
function XML_Error(title,desc)
{
var errorXML =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
\ \ \ " + title + " \ " + desc + " \ \ \
";
var doc = atv.parseXML(errorXML);
atv.loadXML(doc);
};
Now, i figured out a Problem with german umlauts and special chars like [ ], that was before also. If there german umlauts in the title, the trailer function won't started. The Problem, the PrePlay.xml is parsed with the umlauts in the function call:
I don't know, where or how the Video/title is created, but for the Button the german umlauts have to changed and special chars removed.
Second thing, maybe someone want to include this to the project, so he can add a var to the config for trailer language and get this var in the trailers.js youtube search url and add a public google api key.
First thing, i hope the german umlauts and special char problem can be done by ibaa in the project :)
regards
Manuel