Interception of repeated save
This commit is contained in:
36
src/data.go
36
src/data.go
@@ -454,8 +454,40 @@ func saveXEpgMapping(request RequestStruct) (err error) {
|
|||||||
|
|
||||||
Data.XEPG.Channels = request.EpgMapping
|
Data.XEPG.Channels = request.EpgMapping
|
||||||
|
|
||||||
cleanupXEPG()
|
if System.ScanInProgress == 0 {
|
||||||
buildXEPG(true)
|
|
||||||
|
cleanupXEPG()
|
||||||
|
buildXEPG(true)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// Wenn während des erstellen der Datanbank das Mapping erneut gespeichert wird, wird die Datenbank erst später erneut aktualisiert.
|
||||||
|
go func() {
|
||||||
|
|
||||||
|
if System.BackgroundProcess == true {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
System.BackgroundProcess = true
|
||||||
|
|
||||||
|
for {
|
||||||
|
time.Sleep(time.Duration(1) * time.Second)
|
||||||
|
fmt.Println("Scan", System.ScanInProgress)
|
||||||
|
if System.ScanInProgress == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanupXEPG()
|
||||||
|
buildXEPG(false)
|
||||||
|
|
||||||
|
System.BackgroundProcess = false
|
||||||
|
|
||||||
|
}()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package m3u
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -12,6 +14,7 @@ func MakeInterfaceFromM3U(byteStream []byte) (allChannels []interface{}, err err
|
|||||||
|
|
||||||
var content = string(byteStream)
|
var content = string(byteStream)
|
||||||
var channelName string
|
var channelName string
|
||||||
|
var uuids []string
|
||||||
|
|
||||||
var parseMetaData = func(channel string) (stream map[string]string) {
|
var parseMetaData = func(channel string) (stream map[string]string) {
|
||||||
|
|
||||||
@@ -53,7 +56,7 @@ func MakeInterfaceFromM3U(byteStream []byte) (allChannels []interface{}, err err
|
|||||||
line = strings.Replace(line, p, "", 1)
|
line = strings.Replace(line, p, "", 1)
|
||||||
|
|
||||||
p = strings.Replace(p, `"`, "", -1)
|
p = strings.Replace(p, `"`, "", -1)
|
||||||
var parameter = strings.Split(p, "=")
|
var parameter = strings.SplitN(p, "=", 2)
|
||||||
|
|
||||||
if len(parameter) == 2 {
|
if len(parameter) == 2 {
|
||||||
|
|
||||||
@@ -120,9 +123,15 @@ func MakeInterfaceFromM3U(byteStream []byte) (allChannels []interface{}, err err
|
|||||||
|
|
||||||
if strings.Contains(strings.ToLower(key), "id") {
|
if strings.Contains(strings.ToLower(key), "id") {
|
||||||
|
|
||||||
|
if indexOfString(value, uuids) != -1 {
|
||||||
|
log.Println(fmt.Sprintf("Channel: %s - %s = %s ", stream["name"], key, value))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
uuids = append(uuids, value)
|
||||||
|
|
||||||
stream["_uuid.key"] = key
|
stream["_uuid.key"] = key
|
||||||
stream["_uuid.value"] = value
|
stream["_uuid.value"] = value
|
||||||
//os.Exit(0)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -160,3 +169,14 @@ func MakeInterfaceFromM3U(byteStream []byte) (allChannels []interface{}, err err
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func indexOfString(element string, data []string) int {
|
||||||
|
|
||||||
|
for k, v := range data {
|
||||||
|
if element == v {
|
||||||
|
return k
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ type SystemStruct struct {
|
|||||||
APIVersion string
|
APIVersion string
|
||||||
AppName string
|
AppName string
|
||||||
ARCH string
|
ARCH string
|
||||||
|
BackgroundProcess bool
|
||||||
Branch string
|
Branch string
|
||||||
Build string
|
Build string
|
||||||
Compatibility string
|
Compatibility string
|
||||||
|
|||||||
Reference in New Issue
Block a user