#106 Allow group-title customization in channels.

This commit is contained in:
vexorian 2021-01-24 21:33:30 -04:00
parent 42330a1215
commit 1978a9e837
5 changed files with 68 additions and 14 deletions

View File

@ -627,6 +627,13 @@ function api(db, channelDB, fillerDB, xmltvInterval, guideService, _m3uService
}
function cleanUpChannel(channel) {
if (
(typeof(channel.groupTitle) === 'undefined')
||
(channel.groupTitle === '')
) {
channel.groupTitle = "dizqueTV";
}
channel.programs.forEach( cleanUpProgram );
delete channel.fillerContent;
delete channel.filler;

View File

@ -20,7 +20,7 @@
const path = require('path');
var fs = require('fs');
const TARGET_VERSION = 801;
const TARGET_VERSION = 802;
const STEPS = [
// [v, v2, x] : if the current version is v, call x(db), and version becomes v2
@ -41,6 +41,7 @@ const STEPS = [
// but we have to migrate it to 800 using the reAddIcon.
[ 702, 800, (db,channels,dir) => reAddIcon(dir) ],
[ 800, 801, (db) => addImageCache(db) ],
[ 801, 802, () => addGroupTitle() ],
]
const { v4: uuidv4 } = require('uuid');
@ -741,7 +742,7 @@ function migrateWatermark(db, channelDB) {
return channel;
}
console.log("Extracting fillers from channels...");
console.log("Migrating watermarks...");
let channels = path.join(process.env.DATABASE, 'channels');
let channelFiles = fs.readdirSync(channels);
for (let i = 0; i < channelFiles.length; i++) {
@ -811,6 +812,30 @@ function addImageCache(db) {
fs.writeFileSync( f, JSON.stringify( [xmltvSettings] ) );
}
function addGroupTitle() {
function migrateChannel(channel) {
channel.groupTitle= "dizqueTV";
return channel;
}
console.log("Adding group title to channels...");
let channels = path.join(process.env.DATABASE, 'channels');
let channelFiles = fs.readdirSync(channels);
for (let i = 0; i < channelFiles.length; i++) {
if (path.extname( channelFiles[i] ) === '.json') {
console.log("Adding group title to channel : " + channelFiles[i] +"..." );
let channelPath = path.join(channels, channelFiles[i]);
let channel = JSON.parse(fs.readFileSync(channelPath, 'utf-8'));
channel = migrateChannel(channel);
fs.writeFileSync( channelPath, JSON.stringify(channel), 'utf-8');
}
}
console.log("Done migrating group titles in channels.");
}
module.exports = {
initDB: initDB,

View File

@ -50,7 +50,7 @@ class M3uService {
for (var i = 0; i < channels.length; i++) {
if (channels[i].stealth !== true) {
data += `#EXTINF:0 tvg-id="${channels[i].number}" CUID="${channels[i].number}" tvg-chno="${channels[i].number}" tvg-name="${channels[i].name}" tvg-logo="${channels[i].icon}" group-title="dizqueTV",${channels[i].name}\n`
data += `#EXTINF:0 tvg-id="${channels[i].number}" CUID="${channels[i].number}" tvg-chno="${channels[i].number}" tvg-name="${channels[i].name}" tvg-logo="${channels[i].icon}" group-title="${channels[i].groupTitle}",${channels[i].name}\n`
data += `{{host}}/video?channel=${channels[i].number}\n`
}
}

View File

@ -60,6 +60,7 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions) {
scope.channel.guideMinimumDurationSeconds = 5 * 60;
scope.isNewChannel = true
scope.channel.icon = `${$location.protocol()}://${location.host}/images/dizquetv.png`
scope.channel.groupTitle = "dizqueTV";
scope.channel.disableFillerOverlay = true;
scope.channel.iconWidth = 120
scope.channel.iconDuration = 60
@ -95,6 +96,14 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions) {
scope.channel.watermark = defaultWatermark();
}
if (
(typeof(scope.channel.groupTitle) === 'undefined')
||
(scope.channel.groupTitle === '')
) {
scope.channel.groupTitle = "dizqueTV";
}
if (typeof(scope.channel.fillerRepeatCooldown) === 'undefined') {
scope.channel.fillerRepeatCooldown = 30 * 60 * 1000;
}

View File

@ -21,16 +21,28 @@
</div>
<!-- ============= TAB: PROPERTIES ========================= -->
<div class="modal-body" ng-if="tab == 'basic'">
<div>
<span class="pull-right text-danger">{{error.number}}</span>
<label id="channelNumber" class="small">Ch. #</label>
<input for="channelNumber" class="form-control form-control-sm" type="number" ng-model="channel.number" />
<div class='form-group'>
<label class='form-label' >Channel Number:</label>
<input type="text" class='form-control' type='number' ng-model="channel.number" id='channelNumber' aria-describedby="channelNumberHelp" />
<small id='channelNumberHelp' class="text-danger" for='channelNumber'>{{error.number}}</small>
</div>
<div>
<span class="pull-right text-danger">{{error.name}}</span>
<label id="channelName" class="small">Channel Name</label>
<input for="channelName" class="form-control form-control-sm" type="text" ng-model="channel.name" />
<div class='form-group'>
<label class='form-label' >Channel Name:</label>
<input type="text" class='form-control' ng-model="channel.name" id='channelName' aria-describedby="channelNameHelp" />
<small id='channelNumberHelp' class="text-danger" for='channelNumber'>{{error.name}}</small>
</div>
<div class='form-group'>
<label class='form-label' >Channel Group:</label>
<input type="text" class='form-control' ng-model="channel.groupTitle" id='groupTitle' placeholder="dizqueTV" aria-describedby="groupTitleHelp" />
<small id='groupTitleHelp' class="text-muted" for='channelNumber'>This is used by iptv clients to categorize the channels. You can leave it as dizqueTV if you don&apos;t need this sort of classification.</small>
</div>
<div>
<span class="pull-right text-danger">{{error.icon}}</span>
<label for="channelIcon" class="small">Channel Icon</label>
@ -48,8 +60,9 @@
</div>
</div>
<br />
<div>
<h6>Channel Icon Preview</h6>
<h6>Preview</h6>
<img ng-if="channel.icon !== ''" ng-src="{{channel.icon}}" alt="{{channel.name}}" style="max-height: 120px;"/>
<span ng-if="channel.icon === ''">{{channel.name}}</span>
</div>
@ -793,14 +806,14 @@
<div class="form-group col-sm-auto">
<label for="channelBitrate">Video Bitrate (k:</label>
<label for="channelBitrate">Video Bitrate (K):</label>
<input id='channelBitrate' class='form-control' type='number' ng-model='channel.transcoding.videoBitrate' min=0 placeholder='{{videoRateDefault}}'>
</input>
<small class='text-muted form-text'>Leave unassigned to use the global setting</small>
</div>
<div class="form-group col-sm-auto">
<label for="channelBufsize">Video Buffer Size (k):</label>
<label for="channelBufsize">Video Buffer Size (K):</label>
<input id='channelBufsize' class='form-control' type='number' ng-model='channel.transcoding.videoBufSize' min=0 placeholder='{{videoBufSizeDefault}}'>
</input>
<small class='text-muted form-text'>Leave unassigned to use the global setting</small>