Skip to content

Commit

Permalink
Merge branch 'dev/1.4.x' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
vexorian committed Sep 20, 2021
2 parents 41627ca + c2ffc65 commit 989d37d
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile-nvidia
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
28 changes: 22 additions & 6 deletions src/dao/channel-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/dao/plex-server-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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') {
Expand Down
2 changes: 1 addition & 1 deletion src/database-migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 15 additions & 3 deletions src/services/tv-guide-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions web/controllers/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})


Expand Down
14 changes: 13 additions & 1 deletion web/directives/channel-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";
Expand Down Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion web/directives/plex-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion web/public/views/version.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ <h5>
<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>

0 comments on commit 989d37d

Please sign in to comment.