v2.1.1.0110

This commit is contained in:
marmei
2019-12-13 20:31:23 +01:00
19 changed files with 227 additions and 55 deletions

View File

@@ -261,7 +261,9 @@ func bufferingStream(playlistID, streamingURL, channelName string, w http.Respon
var oldSegments []string
for { // Loop 2: Temporäre Datein sind vorhanden, Daten können zum Client gesendet werden
// HTTP Clientverbindung überwachen
cn, ok := w.(http.CloseNotifier)
if ok {
@@ -450,6 +452,9 @@ func getTmpFiles(stream *ThisStream) (tmpFiles []string) {
func killClientConnection(streamID int, playlistID string, force bool) {
Lock.Lock()
defer Lock.Unlock()
if p, ok := BufferInformation.Load(playlistID); ok {
var playlist = p.(Playlist)
@@ -494,6 +499,8 @@ func killClientConnection(streamID int, playlistID string, force bool) {
func clientConnection(stream ThisStream) (status bool) {
status = true
Lock.Lock()
defer Lock.Unlock()
if _, ok := BufferClients.Load(stream.PlaylistID + stream.MD5); !ok {
@@ -902,6 +909,8 @@ func connectToStreamingServer(streamID int, playlistID string) {
// Buffer auf die Festplatte speichern
if fileSize >= tmpFileSize/2 || n == 0 {
Lock.Lock()
bandwidth.Stop = time.Now()
bandwidth.Size += fileSize
@@ -920,6 +929,7 @@ func connectToStreamingServer(streamID int, playlistID string) {
stream.Status = true
playlist.Streams[streamID] = stream
BufferInformation.Store(playlistID, playlist)
Lock.Unlock()
tmpSegment++
@@ -1409,8 +1419,37 @@ func thirdPartyBuffer(streamID int, playlistID string) {
return
}
var args = strings.Replace(options, "[URL]", url, -1)
var cmd = exec.Command(path, strings.Split(args, " ")...)
//args = strings.Replace(args, "[USER-AGENT]", Settings.UserAgent, -1)
// User-Agent setzen
var args []string
for i, a := range strings.Split(options, " ") {
switch bufferType {
case "FFMPEG":
a = strings.Replace(a, "[URL]", url, -1)
if i == 0 {
args = []string{"-user-agent", Settings.UserAgent}
}
args = append(args, a)
case "VLC":
if a == "[URL]" {
a = strings.Replace(a, "[URL]", url, -1)
args = append(args, a)
args = append(args, fmt.Sprintf(":http-user-agent=%s", Settings.UserAgent))
} else {
args = append(args, a)
}
}
}
var cmd = exec.Command(path, args...)
debug = fmt.Sprintf("%s:%s %s", bufferType, path, args)
showDebug(debug, 1)
@@ -1552,9 +1591,11 @@ func thirdPartyBuffer(streamID int, playlistID string) {
tmpSegment++
if stream.Status == false {
Lock.Lock()
stream.Status = true
playlist.Streams[streamID] = stream
BufferInformation.Store(playlistID, playlist)
Lock.Unlock()
}
tmpFile = fmt.Sprintf("%s%d.ts", tmpFolder, tmpSegment)

View File

@@ -29,6 +29,9 @@ var BufferInformation sync.Map
// BufferClients : Anzahl der Clients die einen Stream über den Buffer abspielen
var BufferClients sync.Map
// Lock : Lock Map
var Lock = sync.RWMutex{}
// Init : Systeminitialisierung
func Init() (err error) {
@@ -220,6 +223,8 @@ func StartSystem(updateProviderFiles bool) (err error) {
return
}
setURLScheme()
// Systeminformationen in der Konsole ausgeben
showInfo(fmt.Sprintf("UUID:%s", Settings.UUID))
showInfo(fmt.Sprintf("Tuner (Plex / Emby):%d", Settings.Tuner))

View File

@@ -107,6 +107,9 @@ func updateServerSettings(request RequestStruct) (settings SettingsStrcut, err e
}
case "scheme.m3u", "scheme.xml":
createXEPGFiles = true
}
oldSettings[key] = value
@@ -141,6 +144,8 @@ func updateServerSettings(request RequestStruct) (settings SettingsStrcut, err e
return
}
setURLScheme()
if Settings.AuthenticationWEB == false {
Settings.AuthenticationAPI = false
@@ -505,7 +510,7 @@ func saveXEpgMapping(request RequestStruct) (err error) {
System.ScanInProgress = 1
cleanupXEPG()
//buildXEPG(true)
buildXEPG(true)
go func() {
@@ -540,8 +545,7 @@ func saveXEpgMapping(request RequestStruct) (err error) {
System.ScanInProgress = 1
cleanupXEPG()
//buildXEPG(false)
buildXEPG(false)
createXMLTVFile()
createM3UFile()
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))

View File

@@ -45,7 +45,7 @@ func getCacheImageURL(imageURL string) (cacheImageURL string) {
if indexOfString(urlMD5+fileExtension, Data.Cache.ImagesCache) != -1 {
cacheImageURL = fmt.Sprintf("%s://%s/images/%s%s", System.ServerProtocol.WEB, System.Domain, urlMD5, fileExtension)
cacheImageURL = fmt.Sprintf("%s://%s/images/%s%s", System.ServerProtocol.XML, System.Domain, urlMD5, fileExtension)
} else {
@@ -163,7 +163,7 @@ func uploadLogo(input, filename string) (logoURL string, err error) {
return
}
logoURL = fmt.Sprintf("%s://%s/data_images/%s", System.ServerProtocol.WEB, System.Domain, filename)
logoURL = fmt.Sprintf("%s://%s/data_images/%s", System.ServerProtocol.XML, System.Domain, filename)
return

View File

@@ -187,6 +187,7 @@ type XEPGChannelStruct struct {
XName string `json:"x-name,required"`
XUpdateChannelIcon bool `json:"x-update-channel-icon,required"`
XUpdateChannelName bool `json:"x-update-channel-name,required"`
XDescription string `json:"x-description,required"`
}
// M3UChannelStructXEPG : M3U Struktur für XEPG
@@ -279,6 +280,8 @@ type SettingsStrcut struct {
MappingFirstChannel float64 `json:"mapping.first.channel"`
Port string `json:"port"`
SSDP bool `json:"ssdp"`
SchemeM3U string `json:"scheme.m3u"`
SchemeXML string `json:"scheme.xml"`
TempPath string `json:"temp.path"`
Tuner int `json:"tuner"`
Update []string `json:"update"`

View File

@@ -41,6 +41,8 @@ type RequestStruct struct {
UserAgent *string `json:"user.agent,omitempty"`
XepgReplaceMissingImages *bool `json:"xepg.replace.missing.images,omitempty"`
XteveAutoUpdate *bool `json:"xteveAutoUpdate,omitempty"`
SchemeM3U *string `json:"scheme.m3u,omitempty"`
SchemeXML *string `json:"scheme.xml,omitempty"`
} `json:"settings,omitempty"`
// Upload Logo

View File

@@ -48,6 +48,7 @@ type Program struct {
PreviouslyShown *PreviouslyShown `xml:"previously-shown"`
New *New `xml:"new"`
Live *Live `xml:"live"`
Premiere *Live `xml:"premiere"`
}
// Title : Programmtitel

View File

@@ -138,6 +138,8 @@ func loadSettings() (settings SettingsStrcut, err error) {
defaults["version"] = System.DBVersion
defaults["xteveAutoUpdate"] = true
defaults["temp.path"] = System.Folder.Temp
defaults["scheme.M3U"] = "HTTP"
defaults["scheme.XML"] = "HTTP"
// Default Werte setzen
for key, value := range defaults {
@@ -252,6 +254,14 @@ func setGlobalDomain(domain string) {
return
}
func setURLScheme() {
System.ServerProtocol.M3U = strings.ToLower(Settings.SchemeM3U)
System.ServerProtocol.XML = strings.ToLower(Settings.SchemeXML)
return
}
// UUID generieren
func createUUID() (uuid string) {
uuid = time.Now().Format("2006-01") + "-" + randomString(4) + "-" + randomString(6)

File diff suppressed because one or more lines are too long

View File

@@ -132,7 +132,7 @@ func Stream(w http.ResponseWriter, r *http.Request) {
switch Settings.Buffer {
case "-":
showInfo(fmt.Sprintf("Buffer:false", Settings.Buffer))
showInfo(fmt.Sprintf("Buffer:false [%s]", Settings.Buffer))
case "xteve":
if strings.Index(streamInfo.URL, "rtsp://") != -1 || strings.Index(streamInfo.URL, "rtp://") != -1 {
@@ -316,10 +316,12 @@ func WS(w http.ResponseWriter, r *http.Request) {
var newToken string
if r.Header.Get("Origin") != "http://"+r.Host {
httpStatusError(w, r, 403)
return
}
/*
if r.Header.Get("Origin") != "http://"+r.Host {
httpStatusError(w, r, 403)
return
}
*/
conn, err := websocket.Upgrade(w, r, w.Header(), 1024, 1024)
if err != nil {

View File

@@ -717,6 +717,9 @@ func getProgramData(xepgChannel XEPGChannelStruct) (xepgXML XMLTV, err error) {
// Live
program.Live = xmltvProgram.Live
// Premiere
program.Premiere = xmltvProgram.Premiere
xepgXML.Program = append(xepgXML.Program, program)
}
@@ -759,7 +762,12 @@ func createDummyProgram(xepgChannel XEPGChannelStruct) (dummyXMLTV XMLTV) {
epg.Start = epgStartTime.Format("20060102150405") + offset
epg.Stop = epgStopTime.Format("20060102150405") + offset
epg.Title = append(epg.Title, &Title{Value: xepgChannel.XName + " (" + epgStartTime.Weekday().String()[0:2] + ". " + epgStartTime.Format("15:04") + " - " + epgStopTime.Format("15:04") + ")", Lang: "en"})
epg.Desc = append(epg.Desc, &Desc{Value: "xTeVe: (" + strconv.Itoa(dummyLength) + " Minutes) " + epgStartTime.Weekday().String() + " " + epgStartTime.Format("15:04") + " - " + epgStopTime.Format("15:04"), Lang: "en"})
if len(xepgChannel.XDescription) == 0 {
epg.Desc = append(epg.Desc, &Desc{Value: "xTeVe: (" + strconv.Itoa(dummyLength) + " Minutes) " + epgStartTime.Weekday().String() + " " + epgStartTime.Format("15:04") + " - " + epgStopTime.Format("15:04"), Lang: "en"})
} else {
epg.Desc = append(epg.Desc, &Desc{Value: xepgChannel.XDescription, Lang: "en"})
}
if Settings.XepgReplaceMissingImages == true {
poster.Src = getCacheImageURL(xepgChannel.TvgLogo)