New channel tools: Replicate and Replicate + Shuffle
This commit is contained in:
parent
2bcb14083e
commit
fa58d59c82
@ -14,7 +14,6 @@ module.exports = function ($timeout, $location, dizquetv) {
|
||||
scope.showHelp = false;
|
||||
scope._frequencyModified = false;
|
||||
scope._frequencyMessage = "";
|
||||
scope.millisecondsOffset = 0;
|
||||
scope.minProgramIndex = 0;
|
||||
scope.episodeMemory = {
|
||||
saved : false,
|
||||
@ -89,8 +88,7 @@ module.exports = function ($timeout, $location, dizquetv) {
|
||||
if (typeof(scope.channel.disableFillerOverlay) === 'undefined') {
|
||||
scope.channel.disableFillerOverlay = true;
|
||||
}
|
||||
scope.millisecondsOffset = (t - offset) % 1000;
|
||||
scope.channel.startTime = new Date(t - offset - scope.millisecondsOffset);
|
||||
scope.channel.startTime = new Date(t - offset);
|
||||
// move runningProgram to index 0
|
||||
scope.channel.programs = scope.channel.programs.slice(runningProgram, this.length)
|
||||
.concat(scope.channel.programs.slice(0, runningProgram) );
|
||||
@ -696,7 +694,6 @@ module.exports = function ($timeout, $location, dizquetv) {
|
||||
let progs = [];
|
||||
let t = scope.channel.startTime.getTime();
|
||||
t = t - t % mod;
|
||||
scope.millisecondsOffset = 0;
|
||||
scope.channel.startTime = new Date(t);
|
||||
function addPad(force) {
|
||||
let m = t % mod;
|
||||
@ -878,10 +875,14 @@ module.exports = function ($timeout, $location, dizquetv) {
|
||||
max = Math.floor(max)
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min
|
||||
}
|
||||
function shuffle(array) {
|
||||
let currentIndex = array.length, temporaryValue, randomIndex
|
||||
while (0 !== currentIndex) {
|
||||
randomIndex = Math.floor(Math.random() * currentIndex)
|
||||
function shuffle(array, lo, hi ) {
|
||||
if (typeof(lo) === 'undefined') {
|
||||
lo = 0;
|
||||
hi = array.length;
|
||||
}
|
||||
let currentIndex = hi, temporaryValue, randomIndex
|
||||
while (lo !== currentIndex) {
|
||||
randomIndex = lo + Math.floor(Math.random() * (currentIndex -lo) );
|
||||
currentIndex -= 1
|
||||
temporaryValue = array[currentIndex]
|
||||
array[currentIndex] = array[randomIndex]
|
||||
@ -938,6 +939,29 @@ module.exports = function ($timeout, $location, dizquetv) {
|
||||
});
|
||||
return progs;
|
||||
}
|
||||
scope.replicate = (t) => {
|
||||
let arr = [];
|
||||
for (let j = 0; j < t; j++) {
|
||||
for (let i = 0; i < scope.channel.programs.length; i++) {
|
||||
arr.push( JSON.parse( angular.toJson(scope.channel.programs[i]) ) );
|
||||
arr[i].$index = i;
|
||||
}
|
||||
}
|
||||
scope.channel.programs = arr;
|
||||
updateChannelDuration();
|
||||
}
|
||||
scope.shuffleReplicate =(t) => {
|
||||
shuffle( scope.channel.programs );
|
||||
let n = scope.channel.programs.length;
|
||||
let a = Math.floor(n / 2);
|
||||
scope.replicate(t);
|
||||
for (let i = 0; i < t; i++) {
|
||||
shuffle( scope.channel.programs, n*i, n*i + a);
|
||||
shuffle( scope.channel.programs, n*i + a, n*i + n);
|
||||
}
|
||||
updateChannelDuration();
|
||||
|
||||
}
|
||||
function cyclicShuffle(array) {
|
||||
let shows = {};
|
||||
let next = {};
|
||||
@ -1025,6 +1049,7 @@ module.exports = function ($timeout, $location, dizquetv) {
|
||||
channelNumbers.push(scope.channels[i].number)
|
||||
// validate
|
||||
var now = new Date()
|
||||
scope.error.any = true;
|
||||
if (typeof channel.number === "undefined" || channel.number === null || channel.number === "")
|
||||
scope.error.number = "Select a channel number"
|
||||
else if (channelNumbers.indexOf(parseInt(channel.number, 10)) !== -1 && scope.isNewChannel) // we need the parseInt for indexOf to work properly
|
||||
@ -1044,13 +1069,13 @@ module.exports = function ($timeout, $location, dizquetv) {
|
||||
else if (channel.programs.length === 0)
|
||||
scope.error.programs = "No programs have been selected. Select at least one program."
|
||||
else {
|
||||
channel.startTime.setMilliseconds( scope.millisecondsOffset);
|
||||
scope.error.any = false;
|
||||
for (let i = 0; i < scope.channel.programs.length; i++) {
|
||||
delete scope.channel.programs[i].$index;
|
||||
}
|
||||
scope.onDone(JSON.parse(angular.toJson(channel)))
|
||||
}
|
||||
$timeout(() => { scope.error = {} }, 3500)
|
||||
$timeout(() => { scope.error = {} }, 60000)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1102,6 +1127,13 @@ module.exports = function ($timeout, $location, dizquetv) {
|
||||
scope._selectedProgram = JSON.parse(angular.toJson(program));
|
||||
}
|
||||
}
|
||||
scope.maxReplicas = () => {
|
||||
if (scope.channel.programs.length == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return Math.floor( 50000 / scope.channel.programs.length );
|
||||
}
|
||||
}
|
||||
scope.removeItem = (x) => {
|
||||
scope.channel.programs.splice(x, 1)
|
||||
updateChannelDuration()
|
||||
|
||||
@ -163,6 +163,13 @@
|
||||
<h6>Reruns</h6>
|
||||
<p>Divides the programming in blocks of 6, 8 or 12 hours then repeats each of the blocks the specified number of times. For example, you can make a channel that plays exactly the same channels in the morning and in the afternoon. </p>
|
||||
|
||||
<h6>Replicate</h6>
|
||||
<p>Makes multiple copies of the schedule and plays them in sequence. Normally this isn't necessary, because dizqueTV will always play the schedule back from the beginning when it finishes. But creating replicas is a useful intermediary step sometimes before applying other transformations. Note that because very large channels can be problematic, there's a limit of 50000 programs to the size of the resulting channel when using this tool.</p>
|
||||
|
||||
<h6>Replicate & Shuffle</h6>
|
||||
<p>Like "Replicate", it will make multiple copies of the programming. In addition it will shuffle the programs, but it will make sure not to have too small a distance between two identical programs.</p>
|
||||
|
||||
|
||||
<h6>Save|Recover Episode Positions</h6>
|
||||
<p>The "Save" button saves the current episodes that are next to be played for each tv show. Then whenever you click the "Recover Episode Popsitions" button, episodes will be rearranged cyclically and they will start with the saved positions. So you can maintain episode sequences even after modifying the channel. If there are any new TV shows, they will start at their current positions. Movies and specials won't change positions.
|
||||
</p>
|
||||
@ -336,6 +343,30 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6" style="padding: 5px;">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<input type="number" class="form-control form-control-sm" placeholder="Repeats" min="1" max="{{maxReplicas()}}" ng-model="replicaCount" style="width:5em">
|
||||
</div>
|
||||
<button ng-disabled="!(replicaCount >= 2)" class="btn btn-sm btn-warning form-control form-control-sm" type="button" ng-click="replicate(replicaCount)">
|
||||
<i class='fas fa-recycle'></i> Replicate
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6" style="padding: 5px;">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<input type="number" class="form-control form-control-sm" placeholder="Repeats" min="1" max="{{maxReplicas()}}" ng-model="randomReplicaCount" style="width:5em">
|
||||
</div>
|
||||
<button ng-disabled="!(randomReplicaCount >= 2)" class="btn btn-sm btn-warning form-control form-control-sm" type="button" ng-click="shuffleReplicate(randomReplicaCount)">
|
||||
<i class='fas fa-dice'></i> Replicate & Shuffle
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="input-group col-md-6" style="padding: 5px;">
|
||||
@ -443,6 +474,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<span class="pull-right text-danger" ng-show="error.any"> <i class='fa fa-exclamation-triangle'></i> There were errors. Please review the form.</span>
|
||||
<div class="text-right">
|
||||
<button class="btn btn-sm btn-link" ng-click="_onDone()">
|
||||
Cancel
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user