Merge pull request #150 from vexorian/20201003_dev

Flex tab for channel editor. Can change how flex time and short videos behave in the TV guide
This commit is contained in:
vexorian 2020-10-03 11:50:42 -04:00 committed by GitHub
commit 189deacba0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 90 additions and 44 deletions

View File

@ -1,7 +1,7 @@
module.exports = {
SLACK: 9999,
TVGUIDE_MAXIMUM_PADDING_LENGTH_MS: 30*60*1000,
STEALTH_DURATION: 5 * 60* 1000,
DEFAULT_GUIDE_STEALTH_DURATION: 5 * 60* 1000,
TVGUIDE_MAXIMUM_FLEX_DURATION : 6 * 60 * 60 * 1000,
TOO_FREQUENT: 100,

View File

@ -173,10 +173,10 @@ class TVGuideService
await this._throttle();
if (
(programs.length > 0)
&& isProgramFlex(x.program)
&& isProgramFlex(x.program, channel)
&& (
(x.program.duration <= constants.TVGUIDE_MAXIMUM_PADDING_LENGTH_MS)
|| isProgramFlex(programs[ programs.length - 1].program)
|| isProgramFlex(programs[ programs.length - 1].program, channel)
)
) {
//meld with previous
@ -185,7 +185,7 @@ class TVGuideService
melded += x.program.duration;
if (
(melded > constants.TVGUIDE_MAXIMUM_PADDING_LENGTH_MS)
&& !isProgramFlex(programs[ programs.length - 1].program)
&& !isProgramFlex(programs[ programs.length - 1].program, channel)
) {
y.program.duration -= melded;
programs[ programs.length - 1] = y;
@ -200,7 +200,7 @@ class TVGuideService
} else {
programs[ programs.length - 1] = y;
}
} else if (isProgramFlex(x.program) ) {
} else if (isProgramFlex(x.program, channel) ) {
melded = 0;
programs.push( {
start: x.start,
@ -222,7 +222,7 @@ class TVGuideService
result.programs = [];
for (let i = 0; i < programs.length; i++) {
await this._throttle();
if (isProgramFlex( programs[i].program) ) {
if (isProgramFlex( programs[i].program, channel) ) {
let start = programs[i].start;
let duration = programs[i].program.duration;
if (start <= t0) {
@ -391,10 +391,21 @@ function _wait(t) {
}
function getChannelStealthDuration(channel) {
if (
(typeof(channel.guideMinimumDurationSeconds) !== 'undefined')
&&
! isNaN(channel.guideMinimumDurationSeconds)
) {
return channel.guideMinimumDurationSeconds * 1000;
} else {
return constants.DEFAULT_GUIDE_STEALTH_DURATION;
}
}
function isProgramFlex(program) {
return program.isOffline || program.duration <= constants.STEALTH_DURATION
function isProgramFlex(program, channel) {
return program.isOffline || program.duration <= getChannelStealthDuration(channel)
}
function clone(o) {
@ -413,8 +424,13 @@ function makeEntry(channel, x) {
let title = undefined;
let icon = undefined;
let sub = undefined;
if (isProgramFlex(x.program)) {
title = channel.name;
if (isProgramFlex(x.program, channel)) {
if ( (typeof(channel.guideFlexPlaceholder) === 'string')
&& channel.guideFlexPlaceholder !== "") {
title = channel.guideFlexPlaceholder;
} else {
title = channel.name;
}
icon = channel.icon;
} else {
title = x.program.showTitle;

View File

@ -29,8 +29,10 @@ module.exports = function ($timeout, $location, dizquetv) {
scope.channel = {}
scope.channel.programs = []
scope.channel.fillerCollections = []
scope.channel.guideFlexPlaceholder = "";
scope.channel.fillerRepeatCooldown = 30 * 60 * 1000;
scope.channel.fallback = [];
scope.channel.guideMinimumDurationSeconds = 5 * 60;
scope.isNewChannel = true
scope.channel.icon = `${$location.protocol()}://${location.host}/images/dizquetv.png`
scope.channel.disableFillerOverlay = true;
@ -95,6 +97,12 @@ module.exports = function ($timeout, $location, dizquetv) {
if (typeof(scope.channel.disableFillerOverlay) === 'undefined') {
scope.channel.disableFillerOverlay = true;
}
if (
(typeof(scope.channel.guideMinimumDurationSeconds) === 'undefined')
|| isNaN(scope.channel.guideMinimumDurationSeconds)
) {
scope.channel.guideMinimumDurationSeconds = 5 * 60;
}
scope.channel.startTime = new Date(t - offset);
// move runningProgram to index 0
scope.channel.programs = scope.channel.programs.slice(runningProgram, this.length)
@ -121,6 +129,15 @@ module.exports = function ($timeout, $location, dizquetv) {
}
}
scope.tabOptions = [
{ name: "Properties", id: "basic" },
{ name: "Programming", id: "programming" },
{ name: "Flex", id: "flex" },
{ name: "EPG", id: "epg" },
];
scope.setTab = (tab) => {
scope.tab = tab;
}
if (scope.isNewChannel) {
scope.tab = "basic";

View File

@ -3,34 +3,14 @@
<div ng-class="{'channel-editor-modal-big':showShuffleOptions, 'modal-dialog-scrollable': (tab !== 'programming') }" class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<ul class="nav nav-tabs">
<li class="nav-item">
<span class="nav-link btn btn-link {{ tab === 'basic' ? 'active' : ''}}" ng-click="tab = 'basic'">
<span ng-if="error.tab==='basic'" class='text-danger'>
<i class='fas fa-exclamation-triangle' ></i> Properties
<ul class="nav nav-tabs" >
<li class="nav-item" ng-repeat="x in tabOptions" >
<span class="nav-link btn btn-link {{ tab === x.id ? 'active' : ''}}" ng-click="setTab(x.id)">
<span ng-if="error.tab===x.id" class='text-danger'>
<i class='fas fa-exclamation-triangle' ></i> {{x.name}}
</span>
<span ng-if="error.tab!=='basic'">
Properties
</span>
</span>
</li>
<li class="nav-item">
<span class="nav-link btn btn-link {{ tab === 'programming' ? 'active' : ''}}" ng-click="tab = 'programming'">
<span ng-if="error.tab==='programming'" class='text-danger'>
<i class='fas fa-exclamation-triangle' ></i> Programming
</span>
<span ng-if="error.tab!=='programming'">
Programming
</span>
</span>
</li>
<li class="nav-item">
<span class="nav-link btn btn-link {{ tab === 'flex' ? 'active' : ''}}" ng-click="tab = 'flex'">
<span ng-if="error.tab==='flex'" class='text-danger'>
<i class='fas fa-exclamation-triangle' ></i> Flex
</span>
<span ng-if="error.tab!=='flex'">
Flex
<span ng-if="error.tab!==x.id">
{{x.name}}
</span>
</span>
</li>
@ -39,6 +19,7 @@
{{ getTitle() }}
</h5>
</div>
<!-- ============= TAB: PROPERTIES ========================= -->
<div class="modal-body" ng-if="tab == 'basic'">
<div>
<span class="pull-right text-danger">{{error.number}}</span>
@ -99,13 +80,10 @@
<hr/>
</div>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="stealth" aria-describedby="stealthHelp" ng-model='channel.stealth'>
<label class="form-check-label" for="stealth">Stealth Mode</label>
<span class='text-muted' id="stealthHelp">(This will hide the channel from TV guides, spoofed HDHR, m3u...)</span>
</div>
</div>
<!--
============= TAB: PROGRAMMING =========================
-->
<div ng-if="tab == 'programming'" class='modal-semi-body'>
<div class='form-group form-row' >
<label for="channelStartTime" class="small col-form-label col-md-auto">Programming Start:</label>
@ -462,6 +440,10 @@
</div>
</div>
<!--
============= TAB: FLEX =========================
-->
<div class="modal-body" ng-if="tab == 'flex'">
<div class='text-center text-info' ng-show='!hasFlex'>
<i class='fas fa-info-circle' ></i> Use programming tools like &quot;Add Padding&quot;, &quot;Add Breaks&quot; or &quot;Add Flex&quot; to add &quot;Flex&quot; time slots to the channel&apos;s programming.
@ -597,6 +579,37 @@
</div>
</div>
<!--
============= TAB: EPG =========================
-->
<div class="modal-body" ng-if="tab == 'epg'">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="stealth" aria-describedby="stealthHelp" ng-model='channel.stealth'>
<label class="form-check-label" for="stealth">Stealth Mode</label>
<span class='text-muted' id="stealthHelp">(This will hide the channel from TV guides, spoofed HDHR, m3u playlist... The channel can still be streamed directly or be used as a redirect target.)</span>
</div>
<br></br>
<div class='form-group' ng-show='! channel.stealth'>
<label class='form-label' >Placeholder program title:</label>
<input type="text" class='form-control' ng-model="channel.guideFlexPlaceholder" placeholder="Leave empty so that it uses the channel&apos;s name" id='guideFlex' aria-describedby="guideFlexHelp" />
<small id='guideFlexHelp' class="text-muted" for='guideFlex'>This is the name of the fake program that will appear in the TV guide when there are no programs to display in that time slot guide. E.g when a large Flex block is scheduled.</small>
</div>
<div class='form-group' ng-show='! channel.stealth'>
<label class='form-label'>Minimum program duration to appear in the TV guide (seconds): </label>
<input type="number" class="form-control" ng-model="channel.guideMinimumDurationSeconds" ng-pattern="/^([1-9][0-9]*)$/" min='0' max='36288000' id='guideFlexTime' aria-describedby="guideFlexTimeHelp" />
<small id='guideFlexTimeHelp' class="text-muted" for='guideFlexTime'>Programs shorter than this value will be treated the same as Flex time. Meaning that the TV Guide will try to meld them with the previous program or display the block of programs as the &quot;place holder program&quot; if they make a large continuous group. Use 0 to disable this feature or use a large value to make the channel report only the placeholder program and not the real programming.</small>
</div>
</div>
<div class="modal-footer">