Fix for modern Plex metadata format #328
bluesfan77
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
For me, Plex would go to a XML page. Newer versions of Plex no longer include IMDb/TVDb IDs in the /search response. The old format had them directly in the guid attribute (e.g. guid="imdb://tt0111161"), but modern Plex uses guid="plex://movie/..." instead. The IMDb/TVDb IDs are now only available as child elements in the individual metadata endpoint (e.g. /library/metadata/9939).
This fix adds a second lookup step — after getting search results, it fetches the full metadata for each result and checks there for the IMDb/TVDb ID match instead.
function getInfoFromPlex(title, movie_id, tvdb_id, plex_url, plex_token) {
return new Promise(resolve => {
const titleUri = title.replace(/&/g,'%26').replace(/#/g,'%23');
const imdbid = "tt" + movie_id;
const url = plex_url + "/search?query=" + titleUri + "&X-Plex-Token=" + plex_token;
GM.xmlHttpRequest({
method: "GET",
timeout: 10000,
url: url,
onload: function(response) {
if (response.status == 200) {
const parser = new DOMParser();
const result = parser.parseFromString(response.responseText, "text/xml");
const videos = $(result).find("Video");
});
}
Beta Was this translation helpful? Give feedback.
All reactions