diff --git a/index.js b/index.js index 484e691..cfe1f39 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,7 @@ const ChannelDB = require("./src/dao/channel-db"); const M3uService = require("./src/services/m3u-service"); const FillerDB = require("./src/dao/filler-db"); const CustomShowDB = require("./src/dao/custom-show-db"); -const TVGuideService = require("./src/tv-guide-service"); +const TVGuideService = require("./src/services/tv-guide-service"); const EventService = require("./src/services/event-service"); const onShutdown = require("node-graceful-shutdown").onShutdown; diff --git a/package.json b/package.json index 2a054bd..708d509 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "package": "sh ./make_dist.sh", "clean": "del-cli --force ./bin ./dist ./.dizquetv ./web/public/bundle.js" }, - "author": "Dan Ferguson", - "license": "ISC", + "author": "vexorian", + "license": "Zlib", "dependencies": { "JSONStream": "1.0.5", "angular": "^1.8.0", @@ -22,7 +22,8 @@ "angular-vs-repeat": "2.0.13", "axios": "^0.21.1", "body-parser": "^1.19.0", - "diskdb": "^0.1.17", + "merge" : "2.1.1", + "diskdb": "0.1.17", "express": "^4.17.1", "express-fileupload": "^1.2.1", "node-graceful-shutdown": "1.1.0", diff --git a/src/api.js b/src/api.js index a00501a..64599bc 100644 --- a/src/api.js +++ b/src/api.js @@ -12,6 +12,7 @@ const Plex = require("./plex.js"); const timeSlotsService = require('./services/time-slots-service'); const randomSlotsService = require('./services/random-slots-service'); +const throttle = require('./services/throttle'); function safeString(object) { let o = object; @@ -280,10 +281,10 @@ function api(db, channelDB, fillerDB, customShowDB, xmltvInterval, guideService return res.status(404).send("Channel doesn't have programs?"); } res.writeHead(200, { - 'Content-Type': 'application.json' + 'Content-Type': 'application/json' }); - let transformStream = JSONStream.stringify(); //false makes it not add 'separators' + let transformStream = JSONStream.stringify(); transformStream.pipe(res); for (let i = 0; i < programs.length; i++) { @@ -1002,7 +1003,7 @@ function api(db, channelDB, fillerDB, customShowDB, xmltvInterval, guideService console.error("time slots error: " + toolRes.userError); return res.status(400).send(toolRes.userError); } - res.status(200).send(toolRes); + await streamToolResult(toolRes, res); } catch(err) { console.error(err); res.status(500).send("Internal error"); @@ -1016,7 +1017,7 @@ function api(db, channelDB, fillerDB, customShowDB, xmltvInterval, guideService console.error("random slots error: " + toolRes.userError); return res.status(400).send(toolRes.userError); } - res.status(200).send(toolRes); + await streamToolResult(toolRes, res); } catch(err) { console.error(err); res.status(500).send("Internal error"); @@ -1068,13 +1069,32 @@ function api(db, channelDB, fillerDB, customShowDB, xmltvInterval, guideService channel.fallback.forEach( cleanUpProgram ); } + async function streamToolResult(toolRes, res) { + let programs = toolRes.programs; + delete toolRes.programs; + let s = JSON.stringify(toolRes); + s = s.slice(0, -1); + console.log( JSON.stringify(toolRes)); + + res.writeHead(200, { + 'Content-Type': 'application/json' + }); + + let transformStream = JSONStream.stringify( + s + ',"programs":[', + ',' , + ']}'); + transformStream.pipe(res); + + for (let i = 0; i < programs.length; i++) { + transformStream.write( programs[i] ); + await throttle(); + } + transformStream.end(); + } + return router } -async function throttle() { - return new Promise((resolve) => { - setImmediate(() => resolve()); - }); -} diff --git a/src/services/random-slots-service.js b/src/services/random-slots-service.js index 2cc6064..5cac49c 100644 --- a/src/services/random-slots-service.js +++ b/src/services/random-slots-service.js @@ -1,6 +1,8 @@ const constants = require("../constants"); const getShowData = require("./get-show-data")(); const random = require('../helperFuncs').random; +const throttle = require('./throttle'); + const MINUTE = 60*1000; const DAY = 24*60*MINUTE; @@ -192,12 +194,6 @@ module.exports = async( programs, schedule ) => { // throttle so that the stream is not affected negatively let steps = 0; - let throttle = async() => { - if (steps++ == 10) { - steps = 0; - await _wait(1); - } - } let showsById = {}; let shows = []; diff --git a/src/services/throttle.js b/src/services/throttle.js new file mode 100644 index 0000000..80e34f1 --- /dev/null +++ b/src/services/throttle.js @@ -0,0 +1,6 @@ +//Adds a slight pause so that long operations +module.exports = function() { + return new Promise((resolve) => { + setImmediate(() => resolve()); + }); +} diff --git a/src/services/time-slots-service.js b/src/services/time-slots-service.js index 64b6115..fe6b6a8 100644 --- a/src/services/time-slots-service.js +++ b/src/services/time-slots-service.js @@ -3,6 +3,7 @@ const constants = require("../constants"); const getShowData = require("./get-show-data")(); const random = require('../helperFuncs').random; +const throttle = require('./throttle'); const MINUTE = 60*1000; const DAY = 24*60*MINUTE; @@ -200,12 +201,6 @@ module.exports = async( programs, schedule ) => { // throttle so that the stream is not affected negatively let steps = 0; - let throttle = async() => { - if (steps++ == 10) { - steps = 0; - await _wait(1); - } - } let showsById = {}; let shows = []; diff --git a/src/tv-guide-service.js b/src/services/tv-guide-service.js similarity index 99% rename from src/tv-guide-service.js rename to src/services/tv-guide-service.js index 84027be..cd3160d 100644 --- a/src/tv-guide-service.js +++ b/src/services/tv-guide-service.js @@ -1,6 +1,7 @@ -const constants = require("./constants"); +const constants = require("../constants"); const FALLBACK_ICON = "https://raw.githubusercontent.com/vexorain/dizquetv/main/resources/dizquetv.png"; +const throttle = require('./throttle'); class TVGuideService { @@ -18,6 +19,7 @@ class TVGuideService this.db = db; this.cacheImageService = cacheImageService; this.eventService = eventService; + this._throttle = throttle; } async get() { @@ -355,11 +357,6 @@ class TVGuideService } } - _throttle() { - return new Promise((resolve) => { - setImmediate(() => resolve()); - }); - } async refreshXML() { let xmltvSettings = this.db['xmltv-settings'].find()[0]; diff --git a/web/public/index.html b/web/public/index.html index f198895..201bd08 100644 --- a/web/public/index.html +++ b/web/public/index.html @@ -15,7 +15,7 @@

- + dizqueTV @@ -42,7 +42,7 @@ M3U -
+

diff --git a/web/public/templates/channel-config.html b/web/public/templates/channel-config.html index 1a6f8ac..baf082d 100644 --- a/web/public/templates/channel-config.html +++ b/web/public/templates/channel-config.html @@ -63,7 +63,7 @@

Preview
- {{channel.name}} + {{channel.name}} {{channel.name}}
@@ -318,9 +318,9 @@
FFMPEG Executable Path (eg: C:\ffmpeg\bin\ffmpeg.exe || /usr/bin/ffmpeg)
- + FFMPEG version 4.2+ required. Check by opening the version tab -
+
Miscellaneous Options
- +
@@ -26,7 +26,7 @@

- +
@@ -36,35 +36,35 @@
Note: If you experience playback issues upon stream start, try increasing this.
-
+
Transcoding Features
- + Transcoding is required for some features like channel overlay and measures to prevent issues when switching episodes. The trade-off is quality loss and additional computing resource requirements.
-
+

-
- + Some possible values are: h264 with Intel Quick Sync: h264_qsv MPEG2 with Intel Quick Sync: mpeg2_qsv @@ -73,10 +73,10 @@ H264: libx264 MacOS: h264_videotoolbox
-
+
- + Some possible values are: aac ac3 (default), ac3_fixed @@ -84,26 +84,26 @@ libmp3lame
-
+

- -
+ +

- -
+ +

Will transcode videos that have FPS higher than this. -
+

Scaling algorithm to use when the transcoder needs to change the video size. -
+

@@ -112,20 +112,20 @@
- -
+ +

- -
+ +

- + Values higher than 100 will boost the audio. -
+

- -
+ +

- +
@@ -133,10 +133,10 @@
If there are issues playing a video, dizqueTV will try to use an error screen as a placeholder while retrying loading the video every 60 seconds. @@ -146,7 +146,7 @@
- + Some clients experience issues when the video stream changes resolution. This option will make dizqueTV convert all videos to the preferred resolution selected above. Otherwise, the preferred resolution will be used as a maximum resolution for transcoding. @@ -154,16 +154,16 @@
-
+

- +
- +
@@ -172,11 +172,11 @@
-
+

- + This will force the preferred number of audio channels and sample rate, in addition it will align the lengths of the audio and video channels. This will prevent audio-related episode transition issues in many clients. Audio will always be transcoded. @@ -184,11 +184,11 @@
-
+

- + Toggling this option will disable channel watermarks regardless of channel settings. diff --git a/web/public/templates/filler-config.html b/web/public/templates/filler-config.html index ca73a27..148506a 100644 --- a/web/public/templates/filler-config.html +++ b/web/public/templates/filler-config.html @@ -19,7 +19,7 @@
Total: {{content.length}}
-
+
-
+
{{x.title}}
diff --git a/web/public/templates/flex-config.html b/web/public/templates/flex-config.html index 090d463..0ea110a 100644 --- a/web/public/templates/flex-config.html +++ b/web/public/templates/flex-config.html @@ -10,7 +10,7 @@
-
-
-
-
+

+

+

+

Configure your Plex Server(s) in Settings

-
-
-
-
-
+

+

+

+

+

@@ -24,18 +24,18 @@   -   +  
@@ -190,11 +190,11 @@
Path Replacements
- +
- +
diff --git a/web/public/templates/program-config.html b/web/public/templates/program-config.html index 015e6d1..5ba9c7f 100644 --- a/web/public/templates/program-config.html +++ b/web/public/templates/program-config.html @@ -17,80 +17,80 @@ - + - + - + - +
Icon Preview
- +
- + - + - + - +
Icon Preview
- +
- + - + - + - + - + - +
Icon Preview
- +
- +
- +
- +
diff --git a/web/public/templates/show-config.html b/web/public/templates/show-config.html index e6af075..44ed9f0 100644 --- a/web/public/templates/show-config.html +++ b/web/public/templates/show-config.html @@ -19,7 +19,7 @@
Total: {{content.length}}
-
+
-
+
{{ getProgramDisplayTitle(x) }}
diff --git a/web/public/templates/xmltv-settings.html b/web/public/templates/xmltv-settings.html index cfd3b97..2826a1b 100644 --- a/web/public/templates/xmltv-settings.html +++ b/web/public/templates/xmltv-settings.html @@ -9,22 +9,22 @@
Output Path
- + You can edit this location in file xmltv-settings.json. -
+

- + How many hours of programming to include in the xmltv file.
- + How often should the xmltv file be updated.
-
+

diff --git a/web/public/views/channels.html b/web/public/views/channels.html index e566eb0..e78c09d 100644 --- a/web/public/views/channels.html +++ b/web/public/views/channels.html @@ -25,7 +25,7 @@ {{x.number}} - {{x.name}} + {{x.name}}
{{x.name}}
{{x.name}} (Stealth) diff --git a/web/public/views/settings.html b/web/public/views/settings.html index e7bcd65..fd901f3 100644 --- a/web/public/views/settings.html +++ b/web/public/views/settings.html @@ -21,7 +21,7 @@ -
+