From 42330a1215ca278209af2392fa63bff30208776d Mon Sep 17 00:00:00 2001 From: vexorian Date: Sun, 24 Jan 2021 20:56:00 -0400 Subject: [PATCH 1/2] Cleanup settings service stuff. --- web/app.js | 1 - web/directives/cache-settings.js | 23 ----------------------- web/public/templates/cache-settings.html | 15 --------------- web/public/views/settings.html | 6 ------ 4 files changed, 45 deletions(-) delete mode 100644 web/directives/cache-settings.js delete mode 100644 web/public/templates/cache-settings.html diff --git a/web/app.js b/web/app.js index 18d161c..af58820 100644 --- a/web/app.js +++ b/web/app.js @@ -15,7 +15,6 @@ app.directive('plexSettings', require('./directives/plex-settings')) app.directive('ffmpegSettings', require('./directives/ffmpeg-settings')) app.directive('xmltvSettings', require('./directives/xmltv-settings')) app.directive('hdhrSettings', require('./directives/hdhr-settings')) -app.directive('cacheSettings', require('./directives/cache-settings')) app.directive('plexLibrary', require('./directives/plex-library')) app.directive('programConfig', require('./directives/program-config')) app.directive('flexConfig', require('./directives/flex-config')) diff --git a/web/directives/cache-settings.js b/web/directives/cache-settings.js deleted file mode 100644 index d37fd99..0000000 --- a/web/directives/cache-settings.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = function (dizquetv) { - return { - restrict: 'E', - templateUrl: 'templates/cache-settings.html', - replace: true, - scope: { - }, - link: function (scope, element, attrs) { - dizquetv.getAllSettings().then((settings) => { - console.warn(settings); - scope.settings = settings; - scope.$apply(); - }); - scope.updateSetting = (setting) => { - const {key, value} = setting; - dizquetv.putSetting(key, !value).then((response) => { - scope.settings = response; - scope.$apply(); - }); - }; - } - } -} \ No newline at end of file diff --git a/web/public/templates/cache-settings.html b/web/public/templates/cache-settings.html deleted file mode 100644 index 376f8c9..0000000 --- a/web/public/templates/cache-settings.html +++ /dev/null @@ -1,15 +0,0 @@ -
-
Cache
- -
-
-
{{setting.title}}
-
- -
-
-
- -
\ No newline at end of file diff --git a/web/public/views/settings.html b/web/public/views/settings.html index 54d0bda..5ef4ff3 100644 --- a/web/public/views/settings.html +++ b/web/public/views/settings.html @@ -20,16 +20,10 @@ HDHR -
- \ No newline at end of file From 1978a9e8376e30508c716f7e9d4d6f04339639c4 Mon Sep 17 00:00:00 2001 From: vexorian Date: Sun, 24 Jan 2021 21:33:30 -0400 Subject: [PATCH 2/2] #106 Allow group-title customization in channels. --- src/api.js | 7 +++++ src/database-migration.js | 29 ++++++++++++++++++-- src/services/m3u-service.js | 2 +- web/directives/channel-config.js | 9 ++++++ web/public/templates/channel-config.html | 35 ++++++++++++++++-------- 5 files changed, 68 insertions(+), 14 deletions(-) diff --git a/src/api.js b/src/api.js index 4f46328..5ab4a41 100644 --- a/src/api.js +++ b/src/api.js @@ -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; diff --git a/src/database-migration.js b/src/database-migration.js index 2634fd5..4cf6321 100644 --- a/src/database-migration.js +++ b/src/database-migration.js @@ -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, diff --git a/src/services/m3u-service.js b/src/services/m3u-service.js index 674e200..f3563b5 100644 --- a/src/services/m3u-service.js +++ b/src/services/m3u-service.js @@ -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` } } diff --git a/web/directives/channel-config.js b/web/directives/channel-config.js index df76d16..fd45176 100644 --- a/web/directives/channel-config.js +++ b/web/directives/channel-config.js @@ -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; } diff --git a/web/public/templates/channel-config.html b/web/public/templates/channel-config.html index 506265a..53606da 100644 --- a/web/public/templates/channel-config.html +++ b/web/public/templates/channel-config.html @@ -21,16 +21,28 @@