Merge branch 'Bugs_in_2.0.2'

This commit is contained in:
marmei
2019-09-07 12:07:55 +02:00
10 changed files with 542 additions and 455 deletions

View File

@@ -205,7 +205,7 @@ func bufferingStream(playlistID, streamingURL, channelName string, w http.Respon
playlist.Streams[streamID] = stream
BufferInformation.Store(playlistID, playlist)
go connectToStreamingServer(streamID, playlist)
go connectToStreamingServer(streamID, playlistID)
showInfo(fmt.Sprintf("Streaming Status:Playlist: %s - Tuner: %d / %d", playlist.PlaylistName, len(playlist.Streams), playlist.Tuner))
@@ -219,6 +219,10 @@ func bufferingStream(playlistID, streamingURL, channelName string, w http.Respon
for { // Loop 1: Warten bis das erste Segment durch den Buffer heruntergeladen wurde
if p, ok := BufferInformation.Load(playlistID); ok {
var playlist = p.(Playlist)
if stream, ok := playlist.Streams[streamID]; ok {
if stream.Status == false {
@@ -377,6 +381,8 @@ func bufferingStream(playlistID, streamingURL, channelName string, w http.Respon
}
} // Ende BufferInformation
} // Ende Loop 1
}
@@ -507,7 +513,11 @@ func clientConnection(stream ThisStream) (status bool) {
return
}
func connectToStreamingServer(streamID int, playlist Playlist) {
func connectToStreamingServer(streamID int, playlistID string) {
if p, ok := BufferInformation.Load(playlistID); ok {
var playlist = p.(Playlist)
var timeOut = 0
var debug string
@@ -548,11 +558,11 @@ func connectToStreamingServer(streamID int, playlist Playlist) {
var stream = playlist.Streams[streamID]
if c, ok := BufferClients.Load(stream.PlaylistID + stream.MD5); ok {
if c, ok := BufferClients.Load(playlistID + stream.MD5); ok {
var clients = c.(ClientConnection)
clients.Error = err
BufferClients.Store(stream.PlaylistID+stream.MD5, clients)
BufferClients.Store(playlistID+stream.MD5, clients)
}
@@ -568,7 +578,7 @@ func connectToStreamingServer(streamID int, playlist Playlist) {
}
// M3U8 Segmente
InitBuffer:
InitBuffer:
defaultSegment()
if len(m3u8Segments) > 30 {
@@ -650,7 +660,7 @@ InitBuffer:
addErrorToStream(err)
killClientConnection(streamID, stream.PlaylistID, true)
killClientConnection(streamID, playlistID, true)
clientConnection(stream)
return
@@ -722,7 +732,7 @@ InitBuffer:
BufferInformation.Store(playlist.PlaylistID, playlist)
addErrorToStream(err)
killClientConnection(streamID, stream.PlaylistID, true)
killClientConnection(streamID, playlistID, true)
clientConnection(stream)
resp.Body.Close()
@@ -891,6 +901,8 @@ InitBuffer:
stream.Status = true
playlist.Streams[streamID] = stream
BufferInformation.Store(playlistID, playlist)
tmpSegment++
tmpFile = fmt.Sprintf("%s%d.ts", tmpFolder, tmpSegment)
@@ -986,6 +998,8 @@ InitBuffer:
} // Ende for loop
} // Ende BufferInformation
}
func parseM3U8(stream *ThisStream) (err error) {

View File

@@ -109,7 +109,7 @@ func Init() (err error) {
// Überprüfen ob xTeVe als root läuft
if os.Geteuid() == 0 {
showWarning(2010)
showWarning(2110)
}
if System.Flag.Debug > 0 {

View File

@@ -397,17 +397,25 @@ func saveFilter(request RequestStruct) (settings SettingsStrcut, err error) {
// Filter aktualisieren / löschen
for key, value := range data.(map[string]interface{}) {
var oldData = filterMap[dataID].(map[string]interface{})
oldData[key] = value
// Filter löschen
if _, ok := data.(map[string]interface{})["delete"]; ok {
delete(filterMap, dataID)
break
}
if filter, ok := data.(map[string]interface{})["filter"].(string); ok {
if len(filter) == 0 {
err = errors.New(getErrMsg(1014))
delete(filterMap, dataID)
return
}
}
var oldData = filterMap[dataID].(map[string]interface{})
oldData[key] = value
}
}
@@ -446,8 +454,39 @@ func saveXEpgMapping(request RequestStruct) (err error) {
Data.XEPG.Channels = request.EpgMapping
if System.ScanInProgress == 0 {
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)
if System.ScanInProgress == 0 {
break
}
}
cleanupXEPG()
buildXEPG(false)
System.BackgroundProcess = false
}()
}
return
}
@@ -612,6 +651,7 @@ func saveWizard(request RequestStruct) (nextStep int, err error) {
}
buildXEPG(false)
System.ScanInProgress = 0
}

View File

@@ -95,7 +95,7 @@ func getLineupStatus() (jsonContent []byte, err error) {
lineupStatus.ScanInProgress = System.ScanInProgress
lineupStatus.ScanPossible = 0
lineupStatus.Source = "Cable"
lineupStatus.SourceList = []string{"IPTV", "Cable"}
lineupStatus.SourceList = []string{"Cable"}
jsonContent, err = json.MarshalIndent(lineupStatus, "", " ")

View File

@@ -2,6 +2,8 @@ package m3u
import (
"errors"
"fmt"
"log"
"net/url"
"regexp"
"strings"
@@ -12,6 +14,7 @@ func MakeInterfaceFromM3U(byteStream []byte) (allChannels []interface{}, err err
var content = string(byteStream)
var channelName string
var uuids []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)
p = strings.Replace(p, `"`, "", -1)
var parameter = strings.Split(p, "=")
var parameter = strings.SplitN(p, "=", 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 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.value"] = value
//os.Exit(0)
break
}
@@ -160,3 +169,14 @@ func MakeInterfaceFromM3U(byteStream []byte) (allChannels []interface{}, err err
return
}
func indexOfString(element string, data []string) int {
for k, v := range data {
if element == v {
return k
}
}
return -1
}

View File

@@ -43,6 +43,10 @@ func filterThisStream(s interface{}) (status bool) {
for _, filter := range Data.Filter {
if filter.Rule == "" {
continue
}
var group, name, search string
var exclude, include string
var match = false

View File

@@ -245,6 +245,8 @@ func getErrMsg(errCode int) (errMsg string) {
errMsg = fmt.Sprintf("Invalid formatting of the time")
case 1013:
errMsg = fmt.Sprintf("Invalid settings file (settings.json), file must be at least version %s", System.Compatibility)
case 1014:
errMsg = fmt.Sprintf("Invalid filter rule")
case 1020:
errMsg = fmt.Sprintf("Data could not be saved, invalid keyword")

View File

@@ -11,6 +11,7 @@ type SystemStruct struct {
APIVersion string
AppName string
ARCH string
BackgroundProcess bool
Branch string
Build string
Compatibility string

View File

@@ -306,7 +306,6 @@ func createXEPGDatabase() (err error) {
}
if len(xepgChannel.XChannelID) == 0 {
fmt.Println(mapToJSON(xepgChannel))
delete(Data.XEPG.Channels, id)
}
@@ -316,6 +315,12 @@ func createXEPGDatabase() (err error) {
}
var xepgChannels = make(map[string]interface{})
for k, v := range Data.XEPG.Channels {
xepgChannels[k] = v
}
for _, dsa := range Data.Streams.Active {
var channelExists = false // Entscheidet ob ein Kanal neu zu Datenbank hinzugefügt werden soll.
@@ -331,7 +336,7 @@ func createXEPGDatabase() (err error) {
Data.Cache.Streams.Active = append(Data.Cache.Streams.Active, m3uChannel.Name)
// XEPG Datenbank durchlaufen um nach dem Kanal zu suchen.
for xepg, dxc := range Data.XEPG.Channels {
for xepg, dxc := range xepgChannels {
var xepgChannel XEPGChannelStruct
err = json.Unmarshal([]byte(mapToJSON(dxc)), &xepgChannel)
@@ -367,6 +372,7 @@ func createXEPGDatabase() (err error) {
//os.Exit(0)
switch channelExists {
case true:
// Bereits vorhandener Kanal
var xepgChannel XEPGChannelStruct

View File

@@ -39,7 +39,7 @@ var GitHub = GitHubStruct{Branch: "master", User: "xteve-project", Repo: "xTeVe-
const Name = "xTeVe"
// Version : Version, die Build Nummer wird in der main func geparst.
const Version = "2.0.2.0020"
const Version = "2.0.2.0023"
// DBVersion : Datanbank Version
const DBVersion = "2.0.0"