Merge branch 'dev/1.4.x' into main

This commit is contained in:
vexorian 2021-09-20 09:32:11 -04:00
commit 989d37dcfc
13 changed files with 71 additions and 18 deletions

View File

@ -6,7 +6,7 @@ COPY --from=vexorian/dizquetv:nexecache /var/nexe/linux-x64-12.16.2 /var/nexe/
COPY . .
RUN npm run build && LINUXBUILD=dizquetv sh make_dist.sh linuxonly
FROM jrottenberg/ffmpeg:4.3-nvidia
FROM jrottenberg/ffmpeg:4.3-nvidia1804
EXPOSE 8000
WORKDIR /home/node/app
ENTRYPOINT [ "./dizquetv" ]

View File

@ -1,4 +1,4 @@
# dizqueTV 1.4.4
# dizqueTV 1.4.5-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.

View File

@ -35,6 +35,12 @@ console.log(
'------------'
`);
const NODE = parseInt( process.version.match(/^[^0-9]*(\d+)\..*$/)[1] );
if (NODE < 12) {
console.error(`WARNING: Your nodejs version ${process.version} is lower than supported. dizqueTV has been tested best on nodejs 12.16.`);
}
for (let i = 0, l = process.argv.length; i < l; i++) {
if ((process.argv[i] === "-p" || process.argv[i] === "--port") && i + 1 !== l)

View File

@ -38,6 +38,7 @@ function api(db, channelDB, fillerDB, customShowDB, xmltvInterval, guideService
res.send( {
"dizquetv" : constants.VERSION_NAME,
"ffmpeg" : v,
"nodejs" : process.version,
} );
} catch(err) {
console.error(err);

View File

@ -5,5 +5,5 @@ module.exports = {
TVGUIDE_MAXIMUM_FLEX_DURATION : 6 * 60 * 60 * 1000,
TOO_FREQUENT: 100,
VERSION_NAME: "1.4.4"
VERSION_NAME: "1.4.5-development"
}

View File

@ -29,10 +29,8 @@ class ChannelDB {
}
async saveChannel(number, json) {
if (typeof(number) === 'undefined') {
throw Error("Mising channel number");
}
let f = path.join(this.folder, `${number}.json` );
await this.validateChannelJson(number, json);
let f = path.join(this.folder, `${json.number}.json` );
return await new Promise( (resolve, reject) => {
let data = undefined;
try {
@ -50,12 +48,30 @@ class ChannelDB {
}
saveChannelSync(number, json) {
json.number = number;
this.validateChannelJson(number, json);
let data = JSON.stringify(json);
let f = path.join(this.folder, `${number}.json` );
let f = path.join(this.folder, `${json.number}.json` );
fs.writeFileSync( f, data );
}
validateChannelJson(number, json) {
json.number = number;
if (typeof(json.number) === 'undefined') {
throw Error("Expected a channel.number");
}
if (typeof(json.number) === 'string') {
try {
json.number = parseInt(json.number);
} catch (err) {
console.error("Error parsing channel number.", err);
}
}
if ( isNaN(json.number)) {
throw Error("channel.number must be a integer");
}
}
async deleteChannel(number) {
let f = path.join(this.folder, `${number}.json` );
await new Promise( (resolve, reject) => {

View File

@ -134,7 +134,7 @@ class PlexServerDB
s = s[0];
let arGuide = server.arGuide;
if (typeof(arGuide) === 'undefined') {
arGuide = true;
arGuide = false;
}
let arChannels = server.arChannels;
if (typeof(arChannels) === 'undefined') {
@ -176,7 +176,7 @@ class PlexServerDB
name = resultName;
let arGuide = server.arGuide;
if (typeof(arGuide) === 'undefined') {
arGuide = true;
arGuide = false;
}
let arChannels = server.arGuide;
if (typeof(arChannels) === 'undefined') {

View File

@ -485,7 +485,7 @@ function splitServersSingleChannels(db, channelDB ) {
let saveServer = (name, uri, accessToken, arGuide, arChannels) => {
if (typeof(arGuide) === 'undefined') {
arGuide = true;
arGuide = false;
}
if (typeof(arChannels) === 'undefined') {
arChannels = false;

View File

@ -11,6 +11,7 @@ class TVGuideService
constructor(xmltv, db, cacheImageService, eventService) {
this.cached = null;
this.lastUpdate = 0;
this.lastBackoff = 100;
this.updateTime = 0;
this.currentUpdate = -1;
this.currentLimit = -1;
@ -34,7 +35,15 @@ class TVGuideService
let t = (new Date()).getTime();
this.updateTime = t;
this.updateLimit = t + limit;
let channels = inputChannels;
let channels = [];
for (let i = 0; i < inputChannels.length; i++) {
if (typeof(inputChannels[i]) !== 'undefined') {
channels.push(inputChannels[i]);
} else {
console.error(`There is an issue with one of the channels provided to TV-guide service, it will be ignored: ${i}` );
}
}
this.updateChannels = channels;
return t;
}
@ -345,10 +354,13 @@ class TVGuideService
this.cached = await this.buildItManaged();
console.log("Internal TV Guide data refreshed at " + (new Date()).toLocaleString() );
await this.refreshXML();
this.lastBackoff = 100;
} catch(err) {
console.error("Unable to update internal guide data", err);
await _wait(100);
console.error("Retrying TV guide...");
let w = Math.min(this.lastBackoff * 2, 300000);
await _wait(w);
this.lastBackoff = w;
console.error(`Retrying TV guide after ${w} milliseconds wait...`);
await this.buildIt();
} finally {

View File

@ -4,6 +4,7 @@ module.exports = function ($scope, dizquetv) {
dizquetv.getVersion().then((version) => {
$scope.version = version.dizquetv;
$scope.ffmpegVersion = version.ffmpeg;
$scope.nodejs = version.nodejs;
})

View File

@ -953,7 +953,7 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions, get
scope.error.any = true;
if (typeof channel.number === "undefined" || channel.number === null || channel.number === "") {
if (typeof channel.number === "undefined" || channel.number === null || channel.number === "" ) {
scope.error.number = "Select a channel number"
scope.error.tab = "basic";
} else if (channelNumbers.indexOf(parseInt(channel.number, 10)) !== -1 && scope.isNewChannel) { // we need the parseInt for indexOf to work properly
@ -962,6 +962,9 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions, get
} else if (!scope.isNewChannel && channel.number !== scope.beforeEditChannelNumber && channelNumbers.indexOf(parseInt(channel.number, 10)) !== -1) {
scope.error.number = "Channel number already in use."
scope.error.tab = "basic";
} else if ( ! checkChannelNumber(channel.number) ) {
scope.error.number = "Invalid channel number.";
scope.error.tab = "basic";
} else if (channel.number < 0 || channel.number > 9999) {
scope.error.name = "Enter a valid number (0-9999)"
scope.error.tab = "basic";
@ -1670,3 +1673,12 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions, get
function validURL(url) {
return /^(ftp|http|https):\/\/[^ "]+$/.test(url);
}
function checkChannelNumber(number) {
if ( /^(([1-9][0-9]*)|(0))$/.test(number) ) {
let x = parseInt(number);
return (0 <= x && x < 10000);
} else {
return false;
}
}

View File

@ -192,7 +192,7 @@ module.exports = function (plex, dizquetv, $timeout) {
accessToken: server.accessToken,
}
}
connection.arGuide = true
connection.arGuide = false
connection.arChannels = false // should not be enabled unless dizqueTV tuner already added to plex
await dizquetv.addPlexServer(connection);
} catch (err) {

View File

@ -20,7 +20,12 @@
<td>FFMPEG</td>
<td><div class='loader' ng-if="version.length &lt;= 0"></div>{{ffmpegVersion}}</td>
</tr>
<!-- coming soon, ffmpeg version, nodejs version, plex version, whatever can be used to help debug things-->
<tr>
<td>nodejs</td>
<td><div class='loader' ng-if="version.length &lt;= 0"></div>{{nodejs}}</td>
</tr>
<!-- coming soon: plex version, whatever can be used to help debug things-->
</table>
</div>