Add xteve.xml GZIP

This commit is contained in:
marmei
2019-12-16 20:23:05 +01:00
parent aa763726a3
commit 91b80bc8bb
5 changed files with 28 additions and 3 deletions

View File

@@ -146,3 +146,20 @@ func extractGZIP(gzipBody []byte, fileSource string) (body []byte, err error) {
body = resB.Bytes()
return
}
func compressGZIP(data *[]byte, file string) (err error) {
if len(file) != 0 {
f, err := os.Create(file)
if err != nil {
return err
}
w := gzip.NewWriter(f)
w.Write(*data)
w.Close()
}
return
}

View File

@@ -98,6 +98,8 @@ func Init() (err error) {
System.File.XML = getPlatformFile(fmt.Sprintf("%s%s.xml", System.Folder.Data, System.AppName))
System.File.M3U = getPlatformFile(fmt.Sprintf("%s%s.m3u", System.Folder.Data, System.AppName))
System.Compressed.GZxml = getPlatformFile(fmt.Sprintf("%s%s.xml.gz", System.Folder.Data, System.AppName))
err = activatedSystemAuthentication()
if err != nil {
return

View File

@@ -42,6 +42,10 @@ type SystemStruct struct {
XML string
}
Compressed struct {
GZxml string
}
Flag struct {
Branch string
Debug int

View File

@@ -216,7 +216,6 @@ func xTeVe(w http.ResponseWriter, r *http.Request) {
// XMLTV Datei
if strings.Contains(path, "xmltv/") {
w.Header().Set("Content-Type", "application/xml")
requestType = "xml"
file = System.Folder.Data + getFilenameFromPath(path)
@@ -227,6 +226,8 @@ func xTeVe(w http.ResponseWriter, r *http.Request) {
return
}
w.Header().Set("Content-Type", http.DetectContentType([]byte(content)))
}
// M3U Datei

View File

@@ -641,9 +641,10 @@ func createXMLTVFile() (err error) {
var xmlOutput = []byte(xml.Header + string(content))
writeByteToFile(System.File.XML, xmlOutput)
xepgXML = XMLTV{}
showInfo("XEPG:" + fmt.Sprintf("Compress XMLTV file (%s)", System.Compressed.GZxml))
err = compressGZIP(&xmlOutput, System.Compressed.GZxml)
//saveMapToJSONFile(System.File.Images, Data.Cache.ImageCache)
xepgXML = XMLTV{}
return
}