Skip to content
This repository was archived by the owner on May 8, 2022. It is now read-only.

Commit 3ee7d8b

Browse files
committed
Update mapping if it was changed in m3u playlist. Add checkbox for auto update. Closes #22
1 parent 3704f9a commit 3ee7d8b

File tree

12 files changed

+108
-33
lines changed

12 files changed

+108
-33
lines changed

html/css/screen.css

+5
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ tbody {
404404
cursor: not-allowed;
405405
}
406406

407+
#popup-custom input[type=text]:disabled {
408+
color: #666;
409+
cursor: not-allowed;
410+
}
411+
407412
#mapping-detail-table, #user-detail-table {
408413
display: inline-table;
409414
width: 100%;

html/js/base_ts.js

+15
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,21 @@ function toggleChannelStatus(id) {
368368
}
369369
});
370370
}
371+
function toggleGroupUpdateCb(xepgId, target) {
372+
target.className = 'changed';
373+
const groupInput = document.querySelector('input[name="x-group-title"]');
374+
const mapping = getLocalData('mapping', xepgId);
375+
if (target.checked) {
376+
groupInput.dataset.oldValue = groupInput.value;
377+
groupInput.value = mapping['group-title'];
378+
groupInput.disabled = true;
379+
}
380+
else {
381+
groupInput.value = groupInput.dataset.oldValue;
382+
groupInput.disabled = false;
383+
}
384+
groupInput.className = 'changed';
385+
}
371386
function restore() {
372387
if (document.getElementById('upload')) {
373388
document.getElementById('upload').remove();

html/js/menu_ts.js

+11
Original file line numberDiff line numberDiff line change
@@ -1305,10 +1305,21 @@ function openPopUp(dataType, element) {
13051305
var dbKey = "x-group-title";
13061306
var input = content.createInput("text", dbKey, data[dbKey]);
13071307
input.setAttribute("onchange", "javascript: this.className = 'changed'");
1308+
input.dataset.oldValue = data[dbKey];
13081309
content.appendRow("{{.mapping.m3uGroupTitle.title}}", input);
13091310
if (data["group-title"] != undefined) {
13101311
content.description(data["group-title"]);
13111312
}
1313+
if (data["x-update-channel-group"] == true) {
1314+
input.disabled = true;
1315+
}
1316+
// Update channel group checkbox
1317+
var dbKey = "x-update-channel-group";
1318+
var input = content.createCheckbox(dbKey);
1319+
input.setAttribute("onchange", "javascript: toggleGroupUpdateCb('" + id + "', this);");
1320+
input.checked = data[dbKey];
1321+
content.appendRow("{{.mapping.updateChannelGroup.title}}", input);
1322+
content.description("{{.mapping.updateChannelGroup.description}}");
13121323
// XMLTV file
13131324
var dbKey = "x-xmltv-file";
13141325
var xmlFile = data[dbKey];

html/lang/en.json

+6
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@
255255
"placeholder": "",
256256
"description": ""
257257
},
258+
"updateChannelGroup":
259+
{
260+
"title": "Update Channel Group",
261+
"placeholder": "",
262+
"description": "If checked, use group from the database"
263+
},
258264
"channelLogo":
259265
{
260266
"title": "Logo URL",

src/internal/m3u-parser/xteve_m3u_parser.go

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/url"
88
"regexp"
99
"strings"
10+
1011
"github.com/samber/lo"
1112
)
1213

src/struct-system.go

+27-26
Original file line numberDiff line numberDiff line change
@@ -177,32 +177,33 @@ type Filter struct {
177177

178178
// XEPGChannelStruct : XEPG Structure
179179
type XEPGChannelStruct struct {
180-
FileM3UID string `json:"_file.m3u.id,required"`
181-
FileM3UName string `json:"_file.m3u.name,required"`
182-
FileM3UPath string `json:"_file.m3u.path,required"`
183-
GroupTitle string `json:"group-title,required"`
184-
Name string `json:"name,required"`
185-
TvgID string `json:"tvg-id,required"`
186-
TvgLogo string `json:"tvg-logo,required"`
187-
TvgName string `json:"tvg-name,required"`
188-
TvgShift string `json:"tvg-shift,required"`
189-
URL string `json:"url,required"`
190-
UUIDKey string `json:"_uuid.key,required"`
191-
UUIDValue string `json:"_uuid.value,omitempty"`
192-
Values string `json:"_values,required"`
193-
XActive bool `json:"x-active,required"`
194-
XCategory string `json:"x-category,required"`
195-
XChannelID string `json:"x-channelID,required"`
196-
XEPG string `json:"x-epg,required"`
197-
XGroupTitle string `json:"x-group-title,required"`
198-
XMapping string `json:"x-mapping,required"`
199-
XmltvFile string `json:"x-xmltv-file,required"`
200-
XName string `json:"x-name,required"`
201-
XUpdateChannelIcon bool `json:"x-update-channel-icon,required"`
202-
XUpdateChannelName bool `json:"x-update-channel-name,required"`
203-
XDescription string `json:"x-description,required"`
204-
XTimeshift string `json:"x-timeshift,required"`
205-
DefaultMissingEPG string `json:"x-default-missing-epg,required"`
180+
FileM3UID string `json:"_file.m3u.id,required"`
181+
FileM3UName string `json:"_file.m3u.name,required"`
182+
FileM3UPath string `json:"_file.m3u.path,required"`
183+
GroupTitle string `json:"group-title,required"`
184+
Name string `json:"name,required"`
185+
TvgID string `json:"tvg-id,required"`
186+
TvgLogo string `json:"tvg-logo,required"`
187+
TvgName string `json:"tvg-name,required"`
188+
TvgShift string `json:"tvg-shift,required"`
189+
URL string `json:"url,required"`
190+
UUIDKey string `json:"_uuid.key,required"`
191+
UUIDValue string `json:"_uuid.value,omitempty"`
192+
Values string `json:"_values,required"`
193+
XActive bool `json:"x-active,required"`
194+
XCategory string `json:"x-category,required"`
195+
XChannelID string `json:"x-channelID,required"`
196+
XEPG string `json:"x-epg,required"`
197+
XGroupTitle string `json:"x-group-title,required"`
198+
XMapping string `json:"x-mapping,required"`
199+
XmltvFile string `json:"x-xmltv-file,required"`
200+
XName string `json:"x-name,required"`
201+
XUpdateChannelIcon bool `json:"x-update-channel-icon,required"`
202+
XUpdateChannelName bool `json:"x-update-channel-name,required"`
203+
XUpdateChannelGroup bool `json:"x-update-channel-group,required"`
204+
XDescription string `json:"x-description,required"`
205+
XTimeshift string `json:"x-timeshift,required"`
206+
DefaultMissingEPG string `json:"x-default-missing-epg,required"`
206207
}
207208

208209
// M3UChannelStructXEPG : M3U Structure for XEPG

src/update.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ checkVersion:
264264

265265
goto checkVersion
266266

267-
case "2.2.0":
267+
case "2.2.0", "2.2.1":
268268
// If there are changes to the Database in a later update, continue here
269269

270270
break

src/webUI.go

+4-4
Large diffs are not rendered by default.

src/xepg.go

+7
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,13 @@ func createXEPGDatabase() (err error) {
421421
}
422422
}
423423

424+
// Update GroupTitle
425+
xepgChannel.GroupTitle = m3uChannel.GroupTitle
426+
427+
if xepgChannel.XUpdateChannelGroup {
428+
xepgChannel.XGroupTitle = m3uChannel.GroupTitle
429+
}
430+
424431
// Update Channel Logo. Will be overwritten again if the Logo is present in the XMLTV file
425432
if xepgChannel.XUpdateChannelIcon == true {
426433
xepgChannel.TvgLogo = m3uChannel.TvgLogo

ts/base_ts.ts

+18
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,24 @@ function toggleChannelStatus(id:string) {
517517

518518
}
519519

520+
function toggleGroupUpdateCb(xepgId: string, target: HTMLInputElement) {
521+
target.className = 'changed';
522+
523+
const groupInput: HTMLInputElement = document.querySelector('input[name="x-group-title"]');
524+
const mapping = getLocalData('mapping', xepgId);
525+
526+
if (target.checked) {
527+
groupInput.dataset.oldValue = groupInput.value;
528+
groupInput.value = mapping['group-title'];
529+
groupInput.disabled = true;
530+
} else {
531+
groupInput.value = groupInput.dataset.oldValue;
532+
groupInput.disabled = false;
533+
}
534+
535+
groupInput.className = 'changed';
536+
}
537+
520538
function restore() {
521539

522540
if (document.getElementById('upload')) {

ts/menu_ts.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1625,11 +1625,22 @@ function openPopUp(dataType, element) {
16251625
var dbKey:string = "x-group-title"
16261626
var input = content.createInput("text", dbKey, data[dbKey])
16271627
input.setAttribute("onchange", "javascript: this.className = 'changed'")
1628+
input.dataset.oldValue = data[dbKey]
16281629
content.appendRow("{{.mapping.m3uGroupTitle.title}}", input)
1629-
16301630
if (data["group-title"] != undefined) {
16311631
content.description(data["group-title"])
16321632
}
1633+
if (data["x-update-channel-group"] == true) {
1634+
input.disabled = true;
1635+
}
1636+
1637+
// Update channel group checkbox
1638+
var dbKey:string = "x-update-channel-group"
1639+
var input = content.createCheckbox(dbKey)
1640+
input.setAttribute("onchange", "javascript: toggleGroupUpdateCb('" + id + "', this);")
1641+
input.checked = data[dbKey]
1642+
content.appendRow("{{.mapping.updateChannelGroup.title}}", input)
1643+
content.description("{{.mapping.updateChannelGroup.description}}")
16331644

16341645
// XMLTV file
16351646
var dbKey:string = "x-xmltv-file"

xteve.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const Name = "xTeVe"
4242
const Version = "2.2.5.0000"
4343

4444
// DBVersion : Database Version
45-
const DBVersion = "2.2.0"
45+
const DBVersion = "2.2.1"
4646

4747
// APIVersion : API Version
4848
const APIVersion = "1.1.0"

0 commit comments

Comments
 (0)