xml report
This commit is contained in:
46
extract/report.go
Normal file
46
extract/report.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user