Fixed: undefined playlist
This commit is contained in:
43
src/xepg.go
43
src/xepg.go
@@ -8,6 +8,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
@@ -330,21 +331,20 @@ func createXEPGDatabase() (err error) {
|
|||||||
|
|
||||||
var getFreeChannelNumber = func() (xChannelID string) {
|
var getFreeChannelNumber = func() (xChannelID string) {
|
||||||
|
|
||||||
|
sort.Float64s(allChannelNumbers)
|
||||||
|
|
||||||
var firstFreeNumber float64 = Settings.MappingFirstChannel
|
var firstFreeNumber float64 = Settings.MappingFirstChannel
|
||||||
|
|
||||||
if len(allChannelNumbers) > 0 && indexOfFloat64(firstFreeNumber, allChannelNumbers) >= 0 { //channels exist and first channel number is taken
|
for {
|
||||||
firstFreeNumber = allChannelNumbers[len(allChannelNumbers)-1] //Start with last assigned channel number. Avoids checking from the beginning each time
|
|
||||||
firstFreeNumber++
|
|
||||||
}
|
|
||||||
|
|
||||||
newNumber:
|
|
||||||
|
|
||||||
if indexOfFloat64(firstFreeNumber, allChannelNumbers) == -1 {
|
if indexOfFloat64(firstFreeNumber, allChannelNumbers) == -1 {
|
||||||
xChannelID = fmt.Sprintf("%g", firstFreeNumber)
|
xChannelID = fmt.Sprintf("%g", firstFreeNumber)
|
||||||
allChannelNumbers = append(allChannelNumbers, firstFreeNumber)
|
allChannelNumbers = append(allChannelNumbers, firstFreeNumber)
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
firstFreeNumber++
|
firstFreeNumber++
|
||||||
goto newNumber
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -401,7 +401,7 @@ func createXEPGDatabase() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Data.Cache.Streams.Active = append(Data.Cache.Streams.Active, m3uChannel.Name)
|
Data.Cache.Streams.Active = append(Data.Cache.Streams.Active, m3uChannel.Name+m3uChannel.FileM3UID)
|
||||||
|
|
||||||
// Try to find the channel based on matching all known values. If that fails, then move to full channel scan
|
// Try to find the channel based on matching all known values. If that fails, then move to full channel scan
|
||||||
m3uChannelHash := generateHashForChannel(m3uChannel.FileM3UID, m3uChannel.GroupTitle, m3uChannel.TvgID, m3uChannel.TvgName, m3uChannel.UUIDKey, m3uChannel.UUIDValue)
|
m3uChannelHash := generateHashForChannel(m3uChannel.FileM3UID, m3uChannel.GroupTitle, m3uChannel.TvgID, m3uChannel.TvgName, m3uChannel.UUIDKey, m3uChannel.UUIDValue)
|
||||||
@@ -416,6 +416,11 @@ func createXEPGDatabase() (err error) {
|
|||||||
// XEPG Datenbank durchlaufen um nach dem Kanal zu suchen. Run through the XEPG database to search for the channel (full scan)
|
// XEPG Datenbank durchlaufen um nach dem Kanal zu suchen. Run through the XEPG database to search for the channel (full scan)
|
||||||
for _, dxc := range xepgChannelsValuesMap {
|
for _, dxc := range xepgChannelsValuesMap {
|
||||||
|
|
||||||
|
if m3uChannel.FileM3UID == dxc.FileM3UID {
|
||||||
|
|
||||||
|
dxc.FileM3UID = m3uChannel.FileM3UID
|
||||||
|
dxc.FileM3UName = m3uChannel.FileM3UName
|
||||||
|
|
||||||
// Vergleichen des Streams anhand einer UUID in der M3U mit dem Kanal in der Databank. Compare the stream using a UUID in the M3U with the channel in the database
|
// Vergleichen des Streams anhand einer UUID in der M3U mit dem Kanal in der Databank. Compare the stream using a UUID in the M3U with the channel in the database
|
||||||
if len(dxc.UUIDValue) > 0 && len(m3uChannel.UUIDValue) > 0 {
|
if len(dxc.UUIDValue) > 0 && len(m3uChannel.UUIDValue) > 0 {
|
||||||
|
|
||||||
@@ -439,6 +444,8 @@ func createXEPGDatabase() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch channelExists {
|
switch channelExists {
|
||||||
@@ -1024,6 +1031,18 @@ func createM3UFile() {
|
|||||||
// XEPG Datenbank bereinigen
|
// XEPG Datenbank bereinigen
|
||||||
func cleanupXEPG() {
|
func cleanupXEPG() {
|
||||||
|
|
||||||
|
//fmt.Println(Settings.Files.M3U)
|
||||||
|
|
||||||
|
var sourceIDs []string
|
||||||
|
|
||||||
|
for source := range Settings.Files.M3U {
|
||||||
|
sourceIDs = append(sourceIDs, source)
|
||||||
|
}
|
||||||
|
|
||||||
|
for source := range Settings.Files.HDHR {
|
||||||
|
sourceIDs = append(sourceIDs, source)
|
||||||
|
}
|
||||||
|
|
||||||
showInfo("XEPG:" + fmt.Sprintf("Cleanup database"))
|
showInfo("XEPG:" + fmt.Sprintf("Cleanup database"))
|
||||||
Data.XEPG.XEPGCount = 0
|
Data.XEPG.XEPGCount = 0
|
||||||
|
|
||||||
@@ -1033,7 +1052,7 @@ func cleanupXEPG() {
|
|||||||
err := json.Unmarshal([]byte(mapToJSON(dxc)), &xepgChannel)
|
err := json.Unmarshal([]byte(mapToJSON(dxc)), &xepgChannel)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
||||||
if indexOfString(xepgChannel.Name, Data.Cache.Streams.Active) == -1 {
|
if indexOfString(xepgChannel.Name+xepgChannel.FileM3UID, Data.Cache.Streams.Active) == -1 {
|
||||||
delete(Data.XEPG.Channels, id)
|
delete(Data.XEPG.Channels, id)
|
||||||
} else {
|
} else {
|
||||||
if xepgChannel.XActive == true {
|
if xepgChannel.XActive == true {
|
||||||
@@ -1041,6 +1060,10 @@ func cleanupXEPG() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if indexOfString(xepgChannel.FileM3UID, sourceIDs) == -1 {
|
||||||
|
delete(Data.XEPG.Channels, id)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user