Skip to content

Commit

Permalink
Merge pull request DEFENDORe#108 from vexorian/20200910_68
Browse files Browse the repository at this point in the history
0.0.68
  • Loading branch information
vexorian authored Sep 11, 2020
2 parents 0dc116a + 910b56a commit 2b6d148
Show file tree
Hide file tree
Showing 19 changed files with 338 additions and 99 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dizqueTV 0.0.67
# dizqueTV 0.0.68
![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.
Expand Down
20 changes: 15 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,29 @@ let xmltvInterval = {
interval: null,
lastRefresh: null,
updateXML: async () => {
let channels = [];
try {
let getChannelsCached = async() => {
let channelNumbers = await channelDB.getAllChannelNumbers();
channels = await Promise.all( channelNumbers.map( async (x) => {
return await channelCache.getChannelConfig(channelDB, x);
return await Promise.all( channelNumbers.map( async (x) => {
return (await channelCache.getChannelConfig(channelDB, x))[0];
}) );
}

let channels = [];

try {
channels = await getChannelsCached();
let xmltvSettings = db['xmltv-settings'].find()[0];
await guideService.refresh( await channelDB.getAllChannels(), xmltvSettings.cache*60*60*1000 );
let t = guideService.prepareRefresh(channels, xmltvSettings.cache*60*60*1000);
channels = null;

await guideService.refresh(t);
xmltvInterval.lastRefresh = new Date()
console.log('XMLTV Updated at ', xmltvInterval.lastRefresh.toLocaleString());
} catch (err) {
console.error("Unable to update TV guide?", err);
return;
}
channels = await getChannelsCached();

let plexServers = db['plex-servers'].find()
for (let i = 0, l = plexServers.length; i < l; i++) { // Foreach plex server
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"dependencies": {
"angular": "^1.7.9",
"angular-router-browserify": "0.0.2",
"angular-vs-repeat": "2.0.13",
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"diskdb": "^0.1.17",
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module.exports = {
STEALTH_DURATION: 5 * 60* 1000,
TVGUIDE_MAXIMUM_FLEX_DURATION : 6 * 60 * 60 * 1000,

VERSION_NAME: "0.0.67"
VERSION_NAME: "0.0.68"
}
18 changes: 16 additions & 2 deletions src/ffmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class FFMPEG extends events.EventEmitter {
this.audioChannelsSampleRate = this.opts.normalizeAudio;
this.ensureResolution = this.opts.normalizeResolution;
this.volumePercent = this.opts.audioVolumePercent;
this.hasBeenKilled = false;
}
async spawnConcat(streamUrl) {
return await this.spawn(streamUrl, undefined, undefined, undefined, true, false, undefined, true)
Expand Down Expand Up @@ -404,24 +405,37 @@ class FFMPEG extends events.EventEmitter {
let doLogs = this.opts.logFfmpeg && !isConcatPlaylist;
this.ffmpeg = spawn(this.ffmpegPath, ffmpegArgs, { stdio: ['ignore', 'pipe', (doLogs?process.stderr:"ignore") ] } );

this.ffmpeg.on('close', (code) => {
let ffmpegName = (isConcatPlaylist ? "Concat FFMPEG": "Stream FFMPEG");

this.ffmpeg.on('exit', (code, signal) => {
if (code === null) {
console.log( `${ffmpegName} exited due to signal: ${signal}` );
this.emit('close', code)
} else if (code === 0) {
console.log( `${ffmpegName} exited normally.` );
this.emit('end')
} else if (code === 255) {
if (this.hasBeenKilled) {
console.log( `${ffmpegName} finished with code 255.` );
this.emit('close', code)
return;
}
if (! this.sentData) {
this.emit('error', { code: code, cmd: `${this.opts.ffmpegPath} ${ffmpegArgs.join(' ')}` })
}
console.log( `${ffmpegName} exited with code 255.` );
this.emit('close', code)
} else {
console.log( `${ffmpegName} exited with code ${code}.` );
this.emit('error', { code: code, cmd: `${this.opts.ffmpegPath} ${ffmpegArgs.join(' ')}` })
}
})
});

return this.ffmpeg.stdout;
}
kill() {
if (typeof this.ffmpeg != "undefined") {
this.hasBeenKilled = true;
this.ffmpeg.kill()
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/plexTranscoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ class PlexTranscoder {
this.log(` deinterlace: ${deinterlace}`)
this.log(` streamPath: ${this.settings.streamPath}`)



if (this.settings.streamPath === 'direct' || this.settings.forceDirectPlay) {
if (this.settings.enableSubtitles) {
console.log("Direct play is forced, so subtitles are forcibly disabled.");
this.settings.enableSubtitles = false;
}
stream = {directPlay: true}
} else {
try {
Expand Down
13 changes: 11 additions & 2 deletions src/tv-guide-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ class TVGuideService
return this.cached;
}

async refresh(inputChannels, limit) {
prepareRefresh(inputChannels, limit) {
let t = (new Date()).getTime();
this.updateTime = t;
this.updateLimit = t + limit;
let channels = inputChannels.filter( ch => (ch.stealth !== true) );
let channels = inputChannels;
this.updateChannels = channels;
return t;
}

async refresh(t) {
while( this.lastUpdate < t) {
if (this.currentUpdate == -1) {
this.currentUpdate = this.updateTime;
Expand All @@ -47,6 +51,9 @@ class TVGuideService
}

async makeAccumulated(channel) {
if (typeof(channel.programs) === 'undefined') {
throw Error( JSON.stringify(channel).slice(0,200) );
}
let n = channel.programs.length;
let arr = new Array( channel.programs.length + 1);
arr[0] = 0;
Expand Down Expand Up @@ -296,8 +303,10 @@ class TVGuideService
}
} else {
for (let i = 0; i < channels.length; i++) {
if(! channels[i].stealth) {
let programs = await this.getChannelPrograms(t0, t1, channels[i] );
result[ channels[i].number ] = programs;
}
}
}
return result;
Expand Down
3 changes: 2 additions & 1 deletion web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ require('angular-router-browserify')(angular)
require('./ext/lazyload')(angular)
require('./ext/dragdrop')
require('./ext/angularjs-scroll-glue')
require('angular-vs-repeat');

var app = angular.module('myApp', ['ngRoute', 'angularLazyImg', 'dndLists', 'luegg.directives'])
var app = angular.module('myApp', ['ngRoute', 'vs-repeat', 'angularLazyImg', 'dndLists', 'luegg.directives'])

app.service('plex', require('./services/plex'))
app.service('dizquetv', require('./services/dizquetv'))
Expand Down
Loading

0 comments on commit 2b6d148

Please sign in to comment.