From f36b4a13f0dd9609620524ae2decbdddf5e18f19 Mon Sep 17 00:00:00 2001 From: vexorian Date: Mon, 6 Jul 2020 17:37:55 -0400 Subject: [PATCH] Fix xmltv date bug with some time zones. Improve error message when it's not possible to call plex DVRs endpoint --- index.js | 4 +++- src/xmltv.js | 10 +--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 157540d..9ca18fb 100644 --- a/index.js +++ b/index.js @@ -54,7 +54,9 @@ let xmltvInterval = { plex.RefreshGuide(dvrs).then(() => { }, (err) => { console.error(err, i) }) if (plexServers[i].arChannels && channels.length !== 0) plex.RefreshChannels(channels, dvrs).then(() => { }, (err) => { console.error(err, i) }) - }) + }).catch( (err) => { + console.error("There was an error when fetching Plex DVRs. This means pseudoTV couldn't trigger Plex to update its TV guide." + err); + }); } }, (err) => { console.error("Failed to write the xmltv.xml file. Something went wrong. Check your output directory via the web UI and verify file permissions?", err) diff --git a/src/xmltv.js b/src/xmltv.js index bb43089..36f98e2 100644 --- a/src/xmltv.js +++ b/src/xmltv.js @@ -135,13 +135,5 @@ function _writeProgramme(xw, program) { xw.endElement() } function _createXMLTVDate(d) { - function pad(n) { return n < 10 ? '0' + n : n } - var timezone = d.toString().split('GMT') - timezone = timezone[timezone.length - 1].split(' ')[0] - return d.getFullYear() + "" - + pad(d.getMonth() + 1) + "" - + pad(d.getDate()) + "" - + pad(d.getHours()) + "" - + pad(d.getMinutes()) + "" - + pad(d.getSeconds()) + " " + timezone + return d.toISOString().substring(0,19).replace(/[-T:]/g,"") + " +0000"; } \ No newline at end of file