xml report

This commit is contained in:
nuknal
2024-05-22 11:31:08 +08:00
parent 0634b0106e
commit eb6e0bc95a
6 changed files with 93 additions and 8 deletions

46
extract/report.go Normal file
View File

@@ -0,0 +1,46 @@
package extract
import (
"encoding/xml"
"os"
"path/filepath"
)
type Report struct {
XMLName xml.Name `xml:"report"`
SegmentDirRoot string `xml:"segmentDirRoot"`
Segments []Segment `xml:"segments>segment"`
}
type XMLTime struct {
TimeZone string `xml:"timeZone,attr"`
Value string `xml:",chardata"`
}
type Segment struct {
Id string `xml:"segmentId"`
Aux string `xml:"aux"`
Pan string `xml:"pan"`
Mss string `xml:"mss"`
StartTime XMLTime `xml:"startTime"`
EndTime XMLTime `xml:"endTime"`
Meta string `xml:"meta"`
}
func (e *Extractor) Report() error {
os.MkdirAll(filepath.Dir(e.params.Report), 0755)
f, err := os.Create(e.params.Report)
if err != nil {
return err
}
defer f.Close()
data, err := xml.MarshalIndent(e.report, " ", " ")
if err != nil {
return err
}
_, err = f.Write(data)
return err
}