Merge branch 'pr/136' into beta
This commit is contained in:
@@ -46,7 +46,8 @@ func Init() (err error) {
|
|||||||
System.ServerProtocol.M3U = "http"
|
System.ServerProtocol.M3U = "http"
|
||||||
System.ServerProtocol.WEB = "http"
|
System.ServerProtocol.WEB = "http"
|
||||||
System.ServerProtocol.XML = "http"
|
System.ServerProtocol.XML = "http"
|
||||||
System.DVRLimit = 480
|
System.PlexChannelLimit = 480
|
||||||
|
System.UnfilteredChannelLimit = 480
|
||||||
System.Compatibility = "1.4.4"
|
System.Compatibility = "1.4.4"
|
||||||
|
|
||||||
// FFmpeg Default Einstellungen
|
// FFmpeg Default Einstellungen
|
||||||
@@ -229,7 +230,8 @@ func StartSystem(updateProviderFiles bool) (err error) {
|
|||||||
showInfo(fmt.Sprintf("UUID:%s", Settings.UUID))
|
showInfo(fmt.Sprintf("UUID:%s", Settings.UUID))
|
||||||
showInfo(fmt.Sprintf("Tuner (Plex / Emby):%d", Settings.Tuner))
|
showInfo(fmt.Sprintf("Tuner (Plex / Emby):%d", Settings.Tuner))
|
||||||
showInfo(fmt.Sprintf("EPG Source:%s", Settings.EpgSource))
|
showInfo(fmt.Sprintf("EPG Source:%s", Settings.EpgSource))
|
||||||
showInfo(fmt.Sprintf("Plex Channel Limit:%d", System.DVRLimit))
|
showInfo(fmt.Sprintf("Plex Channel Limit:%d", System.PlexChannelLimit))
|
||||||
|
showInfo(fmt.Sprintf("Unfiltered Channel Limit:%d", System.UnfilteredChannelLimit))
|
||||||
|
|
||||||
// Providerdaten aktualisieren
|
// Providerdaten aktualisieren
|
||||||
if len(Settings.Files.M3U) > 0 && Settings.FilesUpdate == true || updateProviderFiles == true {
|
if len(Settings.Files.M3U) > 0 && Settings.FilesUpdate == true || updateProviderFiles == true {
|
||||||
|
|||||||
12
src/data.go
12
src/data.go
@@ -793,9 +793,9 @@ func buildDatabaseDVR() (err error) {
|
|||||||
|
|
||||||
System.ScanInProgress = 1
|
System.ScanInProgress = 1
|
||||||
|
|
||||||
Data.Streams.All = make([]interface{}, 0)
|
Data.Streams.All = make([]interface{}, 0, System.UnfilteredChannelLimit)
|
||||||
Data.Streams.Active = make([]interface{}, 0)
|
Data.Streams.Active = make([]interface{}, 0, System.UnfilteredChannelLimit)
|
||||||
Data.Streams.Inactive = make([]interface{}, 0)
|
Data.Streams.Inactive = make([]interface{}, 0, System.UnfilteredChannelLimit)
|
||||||
Data.Playlist.M3U.Groups.Text = []string{}
|
Data.Playlist.M3U.Groups.Text = []string{}
|
||||||
Data.Playlist.M3U.Groups.Value = []string{}
|
Data.Playlist.M3U.Groups.Value = []string{}
|
||||||
Data.StreamPreviewUI.Active = []string{}
|
Data.StreamPreviewUI.Active = []string{}
|
||||||
@@ -951,7 +951,7 @@ func buildDatabaseDVR() (err error) {
|
|||||||
sort.Strings(Data.Playlist.M3U.Groups.Text)
|
sort.Strings(Data.Playlist.M3U.Groups.Text)
|
||||||
sort.Strings(Data.Playlist.M3U.Groups.Value)
|
sort.Strings(Data.Playlist.M3U.Groups.Value)
|
||||||
|
|
||||||
if len(Data.Streams.Active) == 0 && len(Data.Streams.All) <= System.DVRLimit && len(Settings.Filter) == 0 {
|
if len(Data.Streams.Active) == 0 && len(Data.Streams.All) <= System.UnfilteredChannelLimit && len(Settings.Filter) == 0 {
|
||||||
Data.Streams.Active = Data.Streams.All
|
Data.Streams.Active = Data.Streams.All
|
||||||
Data.Streams.Inactive = make([]interface{}, 0)
|
Data.Streams.Inactive = make([]interface{}, 0)
|
||||||
|
|
||||||
@@ -960,11 +960,11 @@ func buildDatabaseDVR() (err error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(Data.Streams.Active) > System.DVRLimit {
|
if len(Data.Streams.Active) > System.PlexChannelLimit {
|
||||||
showWarning(2000)
|
showWarning(2000)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(Settings.Filter) == 0 && len(Data.Streams.All) > System.DVRLimit {
|
if len(Settings.Filter) == 0 && len(Data.Streams.All) > System.UnfilteredChannelLimit {
|
||||||
showWarning(2001)
|
showWarning(2001)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -300,9 +300,9 @@ func getErrMsg(errCode int) (errMsg string) {
|
|||||||
|
|
||||||
// Warnings
|
// Warnings
|
||||||
case 2000:
|
case 2000:
|
||||||
errMsg = fmt.Sprintf("Plex can not handle more than %d streams. If you do not use Plex, you can ignore this warning.", System.DVRLimit)
|
errMsg = fmt.Sprintf("Plex can not handle more than %d streams. If you do not use Plex, you can ignore this warning.", System.PlexChannelLimit)
|
||||||
case 2001:
|
case 2001:
|
||||||
errMsg = fmt.Sprintf("%s has loaded more than %d streams. Use the filter to reduce the number of streams.", System.Name, System.DVRLimit)
|
errMsg = fmt.Sprintf("%s has loaded more than %d streams. Use the filter to reduce the number of streams.", System.Name, System.UnfilteredChannelLimit)
|
||||||
case 2002:
|
case 2002:
|
||||||
errMsg = fmt.Sprintf("PMS can not play m3u8 streams")
|
errMsg = fmt.Sprintf("PMS can not play m3u8 streams")
|
||||||
case 2003:
|
case 2003:
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ type SystemStruct struct {
|
|||||||
Dev bool
|
Dev bool
|
||||||
DeviceID string
|
DeviceID string
|
||||||
Domain string
|
Domain string
|
||||||
DVRLimit int
|
PlexChannelLimit int
|
||||||
|
UnfilteredChannelLimit int
|
||||||
|
|
||||||
FFmpeg struct {
|
FFmpeg struct {
|
||||||
DefaultOptions string
|
DefaultOptions string
|
||||||
|
|||||||
66
src/xepg.go
66
src/xepg.go
@@ -253,8 +253,9 @@ func createXEPGMapping() {
|
|||||||
// XEPG Datenbank erstellen / aktualisieren
|
// XEPG Datenbank erstellen / aktualisieren
|
||||||
func createXEPGDatabase() (err error) {
|
func createXEPGDatabase() (err error) {
|
||||||
|
|
||||||
var allChannelNumbers []float64
|
var allChannelNumbers = make([]float64, 0, System.UnfilteredChannelLimit)
|
||||||
Data.Cache.Streams.Active = []string{}
|
Data.Cache.Streams.Active = make([]string, 0, System.UnfilteredChannelLimit)
|
||||||
|
Data.XEPG.Channels = make(map[string]interface{}, System.UnfilteredChannelLimit)
|
||||||
|
|
||||||
Data.XEPG.Channels, err = loadJSONFileToMap(System.File.XEPG)
|
Data.XEPG.Channels, err = loadJSONFileToMap(System.File.XEPG)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -281,6 +282,11 @@ func createXEPGDatabase() (err error) {
|
|||||||
|
|
||||||
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
|
||||||
|
firstFreeNumber = allChannelNumbers[len(allChannelNumbers)-1] //Start with last assigned channel number. Avoids checking from the beginning each time
|
||||||
|
firstFreeNumber++
|
||||||
|
}
|
||||||
|
|
||||||
newNumber:
|
newNumber:
|
||||||
|
|
||||||
if indexOfFloat64(firstFreeNumber, allChannelNumbers) == -1 {
|
if indexOfFloat64(firstFreeNumber, allChannelNumbers) == -1 {
|
||||||
@@ -296,7 +302,7 @@ func createXEPGDatabase() (err error) {
|
|||||||
|
|
||||||
showInfo("XEPG:" + "Update database")
|
showInfo("XEPG:" + "Update database")
|
||||||
|
|
||||||
// Kanal mit fehlenden Kanalnummern löschen
|
// Kanal mit fehlenden Kanalnummern löschen. Delete channel with missing channel numbers
|
||||||
for id, dxc := range Data.XEPG.Channels {
|
for id, dxc := range Data.XEPG.Channels {
|
||||||
|
|
||||||
var xepgChannel XEPGChannelStruct
|
var xepgChannel XEPGChannelStruct
|
||||||
@@ -315,17 +321,24 @@ func createXEPGDatabase() (err error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var xepgChannels = make(map[string]interface{})
|
// Make a map of the db channels based on their previously downloaded attributes -- filename, group, title, etc
|
||||||
|
var xepgChannelsValuesMap = make(map[string]XEPGChannelStruct, System.UnfilteredChannelLimit)
|
||||||
|
for _, v := range Data.XEPG.Channels {
|
||||||
|
var channel XEPGChannelStruct
|
||||||
|
err = json.Unmarshal([]byte(mapToJSON(v)), &channel)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for k, v := range Data.XEPG.Channels {
|
xepgChannelsValuesMap[channel.FileM3UID+channel.Name+channel.GroupTitle+channel.TvgID+channel.TvgName+channel.TvgLogo] = channel
|
||||||
xepgChannels[k] = v
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dsa := range Data.Streams.Active {
|
for _, dsa := range Data.Streams.Active {
|
||||||
|
|
||||||
var channelExists = false // Entscheidet ob ein Kanal neu zu Datenbank hinzugefügt werden soll.
|
var channelExists = false // Entscheidet ob ein Kanal neu zu Datenbank hinzugefügt werden soll. Decides whether a channel should be added to the database
|
||||||
var channelHasUUID = false // Überprüft, ob der Kanal (Stream) eindeutige ID's besitzt
|
var channelHasUUID = false // Überprüft, ob der Kanal (Stream) eindeutige ID's besitzt. Checks whether the channel (stream) has unique IDs
|
||||||
var currentXEPGID string // Aktuelle Datenbank ID (XEPG). Wird verwendet, um den Kanal in der Datenbank mit dem Stream der M3u zu aktualisieren
|
var currentXEPGID string // Aktuelle Datenbank ID (XEPG). Wird verwendet, um den Kanal in der Datenbank mit dem Stream der M3u zu aktualisieren. Current database ID (XEPG) Used to update the channel in the database with the stream of the M3u
|
||||||
|
|
||||||
var m3uChannel M3UChannelStructXEPG
|
var m3uChannel M3UChannelStructXEPG
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(mapToJSON(dsa)), &m3uChannel)
|
err = json.Unmarshal([]byte(mapToJSON(dsa)), &m3uChannel)
|
||||||
@@ -335,41 +348,40 @@ func createXEPGDatabase() (err error) {
|
|||||||
|
|
||||||
Data.Cache.Streams.Active = append(Data.Cache.Streams.Active, m3uChannel.Name)
|
Data.Cache.Streams.Active = append(Data.Cache.Streams.Active, m3uChannel.Name)
|
||||||
|
|
||||||
// XEPG Datenbank durchlaufen um nach dem Kanal zu suchen.
|
// Try to find the channel based on matching all known values. If that fails, then move to full channel scan
|
||||||
for xepg, dxc := range xepgChannels {
|
if val, ok := xepgChannelsValuesMap[m3uChannel.FileM3UID+m3uChannel.Name+m3uChannel.GroupTitle+m3uChannel.TvgID+m3uChannel.TvgName+m3uChannel.TvgLogo]; ok {
|
||||||
|
channelExists = true
|
||||||
|
channelHasUUID = false
|
||||||
|
currentXEPGID = val.XEPG
|
||||||
|
} else {
|
||||||
|
|
||||||
var xepgChannel XEPGChannelStruct
|
// XEPG Datenbank durchlaufen um nach dem Kanal zu suchen. Run through the XEPG database to search for the channel (full scan)
|
||||||
err = json.Unmarshal([]byte(mapToJSON(dxc)), &xepgChannel)
|
for _, dxc := range xepgChannelsValuesMap {
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vergleichen des Streams anhand einer UUID in der M3U mit dem Kanal in der Databank
|
// 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(xepgChannel.UUIDValue) > 0 && len(m3uChannel.UUIDValue) > 0 {
|
if len(dxc.UUIDValue) > 0 && len(m3uChannel.UUIDValue) > 0 {
|
||||||
|
|
||||||
if xepgChannel.UUIDValue == m3uChannel.UUIDValue && xepgChannel.UUIDKey == m3uChannel.UUIDKey {
|
if dxc.UUIDValue == m3uChannel.UUIDValue && dxc.UUIDKey == m3uChannel.UUIDKey {
|
||||||
|
|
||||||
channelExists = true
|
channelExists = true
|
||||||
channelHasUUID = true
|
channelHasUUID = true
|
||||||
currentXEPGID = xepg
|
currentXEPGID = dxc.XEPG
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Vergleichen des Streams mit dem Kanal in der Databank anhand des Kanalnamens
|
// Vergleichen des Streams mit dem Kanal in der Databank anhand des Kanalnamens. Compare the stream to the channel in the database using the channel name
|
||||||
//fmt.Println(xepgChannel.Name, xepgChannel.UUIDKey, xepgChannel.UUIDValue)
|
if dxc.Name == m3uChannel.Name {
|
||||||
if xepgChannel.Name == m3uChannel.Name {
|
|
||||||
channelExists = true
|
channelExists = true
|
||||||
currentXEPGID = xepg
|
currentXEPGID = dxc.XEPG
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//os.Exit(0)
|
|
||||||
|
|
||||||
switch channelExists {
|
switch channelExists {
|
||||||
|
|
||||||
@@ -435,7 +447,7 @@ func createXEPGDatabase() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
showInfo("XEPG:" + "Save DB file")
|
||||||
err = saveMapToJSONFile(System.File.XEPG, Data.XEPG.Channels)
|
err = saveMapToJSONFile(System.File.XEPG, Data.XEPG.Channels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user