added touch support, changed appearance, new icons
This commit is contained in:
27
plex.py
Normal file
27
plex.py
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
|
||||
// Start polling for Plex now-playing details
|
||||
checkPlexNowPlaying();
|
||||
setInterval(checkPlexNowPlaying, 3000);
|
||||
|
||||
function checkPlexNowPlaying() {
|
||||
const plexToken = "kbGwoiA_QEGzw7MgSZrY"; // <-- replace with your Plex token
|
||||
const plexHost = "spyro.corp.bbrunson.com"; // <-- adjust if needed
|
||||
const url = `http://${plexHost}:32400/status/sessions?X-Plex-Token=${plexToken}`;
|
||||
http.get(url, (res) => {
|
||||
let data = "";
|
||||
res.on('data', chunk => data += chunk);
|
||||
res.on('end', () => {
|
||||
// For simplicity we check for a known tag in the XML response.
|
||||
let nowPlaying = "No media playing";
|
||||
if(data.includes("MediaContainer") && data.includes("Video")) {
|
||||
nowPlaying = "Plex is playing media";
|
||||
}
|
||||
if(win){
|
||||
win.webContents.send('plex-update', { details: nowPlaying });
|
||||
}
|
||||
});
|
||||
}).on('error', err => {
|
||||
console.error("Error fetching Plex now playing:", err);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user