Last active
August 13, 2021 07:55
-
-
Save amithgc/e6743dcac876d789b427428f143051fd to your computer and use it in GitHub Desktop.
Node-RED Javascript to fetch images for PLEX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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