Merge pull request #201 from vexorian/20201122_dev

20201122 dev
This commit is contained in:
vexorian 2020-11-22 19:21:27 -04:00 committed by GitHub
commit 4e842c71ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 11 deletions

View File

@ -19,6 +19,7 @@
"angular": "^1.7.9",
"angular-router-browserify": "0.0.2",
"angular-vs-repeat": "2.0.13",
"random-js" : "2.1.0",
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"diskdb": "^0.1.17",

View File

@ -6,6 +6,9 @@ module.exports = {
let channelCache = require('./channel-cache');
const SLACK = require('./constants').SLACK;
const randomJS = require("random-js");
const Random = randomJS.Random;
const random = new Random( randomJS.MersenneTwister19937.autoSeed() );
function getCurrentProgramAndTimeElapsed(date, channel) {
let channelStartTime = (new Date(channel.startTime)).getTime();
@ -102,7 +105,7 @@ function createLineup(obj, channel, fillers, isFirst) {
//it's boring and odd to tune into a channel and it's always
//the start of a commercial.
let more = Math.max(0, filler.duration - fillerstart - 15000 - SLACK);
fillerstart += Math.floor(more * Math.random() );
fillerstart += random.integer(0, more);
}
lineup.push({ // just add the video, starting at 0, playing the entire duration
type: 'commercial',
@ -152,12 +155,7 @@ function createLineup(obj, channel, fillers, isFirst) {
}
function weighedPick(a, total) {
if (a==total) {
return true;
} else {
let ran = Math.random();
return ran * total < a;
}
return random.bool(a, total);
}
function pickRandomWithMaxDuration(channel, fillers, maxDuration) {

View File

@ -182,7 +182,7 @@ lang=en`
try {
return this.getVideoStats().videoDecision === "copy";
} catch (e) {
console.log("Error at decision:" + e);
console.log("Error at decision:", e);
return false;
}
}
@ -199,7 +199,7 @@ lang=en`
try {
return this.getVideoStats().videoDecision === "copy" && this.getVideoStats().audioDecision === "copy";
} catch (e) {
console.log("Error at decision:" + e);
console.log("Error at decision:" , e);
return false;
}
}
@ -245,7 +245,7 @@ lang=en`
}
}.bind(this) )
} catch (e) {
console.log("Error at decision:" + e);
console.log("Error at decision:" , e);
}
this.log("Current video stats:")
@ -313,7 +313,7 @@ lang=en`
async getDecision(directPlay) {
try {
this.getDecisionUnmanaged(directPlay);
await this.getDecisionUnmanaged(directPlay);
} catch (err) {
console.error(err);
}