From 1e72f7354387c3c58a195c9d3c0f262ff31df29b Mon Sep 17 00:00:00 2001 From: vexorian Date: Tue, 21 Sep 2021 08:41:09 -0400 Subject: [PATCH 1/3] 1.4.6-development --- README.md | 2 +- src/constants.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f39d0d8..dcd7600 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# dizqueTV 1.4.5-development +# dizqueTV 1.4.6-development ![Discord](https://img.shields.io/discord/711313431457693727?logo=discord&logoColor=fff&style=flat-square) ![GitHub top language](https://img.shields.io/github/languages/top/vexorian/dizquetv?logo=github&style=flat-square) ![Docker Pulls](https://img.shields.io/docker/pulls/vexorian/dizquetv?logo=docker&logoColor=fff&style=flat-square) Create live TV channel streams from media on your Plex servers. diff --git a/src/constants.js b/src/constants.js index 72afbba..4b82b5b 100644 --- a/src/constants.js +++ b/src/constants.js @@ -5,5 +5,5 @@ module.exports = { TVGUIDE_MAXIMUM_FLEX_DURATION : 6 * 60 * 60 * 1000, TOO_FREQUENT: 100, - VERSION_NAME: "1.4.5-development" + VERSION_NAME: "1.4.6-development" } From 0ad1b163695a47beb3da165b7be8c07eb024e447 Mon Sep 17 00:00:00 2001 From: vexorian Date: Tue, 21 Sep 2021 00:11:45 -0400 Subject: [PATCH 2/3] Fix throttler bug --- src/constants.js | 2 +- src/throttler.js | 39 ++++++++++++++++++++++++--------------- src/video.js | 1 + 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/constants.js b/src/constants.js index 4b82b5b..79d990d 100644 --- a/src/constants.js +++ b/src/constants.js @@ -3,7 +3,7 @@ module.exports = { TVGUIDE_MAXIMUM_PADDING_LENGTH_MS: 30*60*1000, DEFAULT_GUIDE_STEALTH_DURATION: 5 * 60* 1000, TVGUIDE_MAXIMUM_FLEX_DURATION : 6 * 60 * 60 * 1000, - TOO_FREQUENT: 100, + TOO_FREQUENT: 1000, VERSION_NAME: "1.4.6-development" } diff --git a/src/throttler.js b/src/throttler.js index 543cbe9..31d1661 100644 --- a/src/throttler.js +++ b/src/throttler.js @@ -15,29 +15,38 @@ function equalItems(a, b) { function wereThereTooManyAttempts(sessionId, lineupItem) { - let obj = cache[sessionId]; + let t1 = (new Date()).getTime(); - if (typeof(obj) === 'undefined') { + + let previous = cache[sessionId]; + if (typeof(previous) === 'undefined') { previous = cache[sessionId] = { - t0: t1 - constants.TOO_FREQUENT * 5 + t0: t1 - constants.TOO_FREQUENT * 5, + lineupItem: null, }; - - } else { - clearTimeout(obj.timer); } - previous.timer = setTimeout( () => { - cache[sessionId].timer = null; - delete cache[sessionId]; - }, constants.TOO_FREQUENT*5 ); - + let result = false; - - if (previous.t0 + constants.TOO_FREQUENT >= t1) { + if (t1 - previous.t0 < constants.TOO_FREQUENT) { //certainly too frequent result = equalItems( previous.lineupItem, lineupItem ); } - cache[sessionId].t0 = t1; - cache[sessionId].lineupItem = lineupItem; + + cache[sessionId] = { + t0: t1, + lineupItem : lineupItem, + }; + + setTimeout( () => { + if ( + (typeof(cache[sessionId]) !== 'undefined') + && + (cache[sessionId].t0 === t1) + ) { + delete cache[sessionId]; + } + }, constants.TOO_FREQUENT * 5 ); + return result; } diff --git a/src/video.js b/src/video.js index 5f7e347..14590e8 100644 --- a/src/video.js +++ b/src/video.js @@ -300,6 +300,7 @@ function video( channelDB , fillerDB, db) { channelCache.recordPlayback(channel.number, t0, lineupItem); } if (wereThereTooManyAttempts(session, lineupItem)) { + console.error("There are too many attempts to play the same item in a short period of time, playing the error stream instead."); lineupItem = { isOffline: true, err: Error("Too many attempts, throttling.."), From 7b174e95a719647cdd368c456194093a11ce35ba Mon Sep 17 00:00:00 2001 From: vexorian Date: Tue, 21 Sep 2021 00:12:08 -0400 Subject: [PATCH 3/3] Fix generator name in xmltv --- src/xmltv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xmltv.js b/src/xmltv.js index 5ca97cf..4b02f5a 100644 --- a/src/xmltv.js +++ b/src/xmltv.js @@ -51,7 +51,7 @@ function writePromise(json, xmlSettings, throttle, cacheImageService) { function _writeDocStart(xw) { xw.startDocument() xw.startElement('tv') - xw.writeAttribute('generator-info-name', 'psuedotv-plex') + xw.writeAttribute('generator-info-name', 'dizquetv') } function _writeDocEnd(xw, ws) { xw.endElement()