Skip to content

Instantly share code, notes, and snippets.

@amithgc
Last active August 13, 2021 07:55
Show Gist options
  • Save amithgc/e6743dcac876d789b427428f143051fd to your computer and use it in GitHub Desktop.
Save amithgc/e6743dcac876d789b427428f143051fd to your computer and use it in GitHub Desktop.
Node-RED Javascript to fetch images for PLEX
var messageContent = "";
if(msg.payload.includes ("playing")) {
messageContent = "Now Playing on PLEX: " + msg.session.title + " (" + msg.session.year + ")";
} else if(msg.payload.includes ("stopped")) {
messageContent = "Stopped Playing on PLEX: " + msg.session.title + " (" + msg.session.year + ")";
}
if(msg.payload.includes ("playing")) {
var id = msg.session.guid;
id = id.replace("com.plexapp.agents.imdb://", "");
id = id.replace("?lang=en", "");
msg.payload = {
chatId :"<YOUR_CHAT_ID>",
type : "photo",
content : "https://m.imdb.com/title/"+id+"/mediaviewer/",
caption : messageContent
}
return msg;
} else if(msg.payload.includes ("stopped")) {
msg.payload = {
chatId :"<YOUR_CHAT_ID>",
type : "message",
content : messageContent
}
return msg;
} else {
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment