summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-12 02:37:52 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-12 02:37:52 (GMT)
commita8a8bc8ba1ef4a04005587430c1e61a1c1d325f3 (patch)
tree15447f00986e523fc1732cf6979931cdc4ed70e5
parentd6dd3675bfe43d0fda64b52eec81efbcd7def828 (diff)
added xml parse for response of rdxport
-rw-r--r--importer.go18
-rw-r--r--rdxport_responses.go150
2 files changed, 150 insertions, 18 deletions
diff --git a/importer.go b/importer.go
index e29e4df..749c895 100644
--- a/importer.go
+++ b/importer.go
@@ -27,10 +27,8 @@ package rhimport
import (
"bufio"
"bytes"
- "encoding/xml"
"fmt"
"github.com/golang-basic/go-curl"
- "io"
"mime/multipart"
"net/http"
"os"
@@ -134,22 +132,6 @@ func NewImportResult(rdres *RDWebResult) *ImportResult {
return res
}
-type RDWebResult struct {
- ResponseCode int `xml:"ResponseCode"`
- ErrorString string `xml:"ErrorString"`
- AudioConvertError int `xml:"AudioConvertError"`
-}
-
-func NewRDWebResultFromXML(data io.Reader) (res *RDWebResult, err error) {
- decoder := xml.NewDecoder(data)
- res = &RDWebResult{}
- if xmlerr := decoder.Decode(res); xmlerr != nil {
- err = fmt.Errorf("Error parsing XML response: %s", xmlerr)
- return
- }
- return
-}
-
func add_cart(ctx *ImportContext) (result *RDWebResult, err error) {
var b bytes.Buffer
w := multipart.NewWriter(&b)
diff --git a/rdxport_responses.go b/rdxport_responses.go
new file mode 100644
index 0000000..db309d9
--- /dev/null
+++ b/rdxport_responses.go
@@ -0,0 +1,150 @@
+//
+// rhimportd
+//
+// The Radio Helsinki Rivendell Import Daemon
+//
+//
+// Copyright (C) 2015 Christian Pointner <equinox@helsinki.at>
+//
+// This file is part of rhimportd.
+//
+// rhimportd is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// rhimportd is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with rhimportd. If not, see <http://www.gnu.org/licenses/>.
+//
+
+package rhimport
+
+import (
+ "encoding/xml"
+ "fmt"
+ "io"
+)
+
+type RDWebResult struct {
+ ResponseCode int `xml:"ResponseCode"`
+ ErrorString string `xml:"ErrorString"`
+ AudioConvertError int `xml:"AudioConvertError"`
+}
+
+func NewRDWebResultFromXML(data io.Reader) (res *RDWebResult, err error) {
+ decoder := xml.NewDecoder(data)
+ res = &RDWebResult{}
+ if xmlerr := decoder.Decode(res); xmlerr != nil {
+ err = fmt.Errorf("Error parsing XML response: %s", xmlerr)
+ return
+ }
+ return
+}
+
+type RDCartAdd struct {
+ Carts []RDCart `xml:"cart"`
+}
+
+type RDCart struct {
+ Number int `xml:"number"`
+ Type string `xml:"type"`
+ GroupName string `xml:"groupName"`
+ Title string `xml:"title"`
+ Artist string `xml:"artist"`
+ Album string `xml:"album"`
+ Year string `xml:"year"`
+ Label string `xml:"label"`
+ Client string `xml:"client"`
+ Agency string `xml:"agency"`
+ Publisher string `xml:"publisher"`
+ Composer string `xml:"composer"`
+ UserDefined string `xml:"userDefined"`
+ UsageCode int `xml:"usageCode"`
+ ForcedLength string `xml:"forcedLength"`
+ AverageLength string `xml:"averageLength"`
+ LengthDeviation string `xml:"lengthDeviation"`
+ AverageSegueLength string `xml:"averageSegueLenth"`
+ AverageHookLength string `xml:"averageHookLength"`
+ CutQuantity int `xml:"cutQuantity"`
+ LastCutPlayer int `xml:"lastCutPlayed"`
+ Validity int `xml:"validity"`
+ EnforceLength bool `xml:"enforceLength"`
+ Asynchronous bool `xml:"asyncronous"`
+ Owner string `xml:"owner"`
+ MetadataDatetime string `xml:"metadataDatetime"`
+}
+
+func NewRDCartAddFromXML(data io.Reader) (cart *RDCartAdd, err error) {
+ decoder := xml.NewDecoder(data)
+ cart = &RDCartAdd{}
+ if xmlerr := decoder.Decode(cart); xmlerr != nil {
+ err = fmt.Errorf("Error parsing XML response: %s", xmlerr)
+ return
+ }
+ return
+}
+
+type RDCutAdd struct {
+ Cuts []RDCut `xml:"cut"`
+}
+
+type RDCut struct {
+ Name string `xml:"cutName"`
+ CartNumber int `xml:"cartNumber"`
+ Number int `xml:"cutNumber"`
+ EverGreen bool `xml:"evergreen"`
+ Description string `xml:"description"`
+ OutCue string `xml:"outcue"`
+ ISRC string `xml:"isrc"`
+ ISCI string `xml:"isci"`
+ Length int `xml:"length"`
+ OriginDateTime string `xml:"originDatetime"`
+ StartDateTime string `xml:"startDatetime"`
+ EndDateTime string `xml:"endDatetime"`
+ Sunday bool `xml:"sun"`
+ Monday bool `xml:"mon"`
+ Tuesday bool `xml:"tue"`
+ Wednesday bool `xml:"wed"`
+ Thursday bool `xml:"thu"`
+ Friday bool `xml:"fri"`
+ Saturday bool `xml:"sat"`
+ StartDaypart string `xml:"startDaypart"`
+ EndDayPart string `xml:"endDaypart"`
+ OriginName string `xml:"originName"`
+ Weight int `xml:"weight"`
+ LastPlayDateTime string `xml:"lastPlayDatetime"`
+ PlayCounter int `xml:"playCounter"`
+ LocalCounter int `xml:"localCounter"`
+ Validiy int `xml:"validity"`
+ CondingFormat int `xml:"codingFormat"`
+ SampleRate int `xml:"sampleRate"`
+ BitRate int `xml:"bitRate"`
+ Channels int `xml:"channels"`
+ PlayGain int `xml:"playGain"`
+ StartPoint int `xml:"startPoint"`
+ EndPoint int `xml:"endPoint"`
+ FadeUpPoint int `xml:"fadeupPoint"`
+ FadeDownPoint int `xml:"fadedownPoint"`
+ SegueStartPoint int `xml:"segueStartPoint"`
+ SegueEndPoint int `xml:"segueEndPoint"`
+ SegueGain int `xml:"segueGain"`
+ HookStartPoint int `xml:"hookStartPoint"`
+ HookEndPoint int `xml:"hookEndPoint"`
+ TalkStartPoint int `xml:"talkStartPoint"`
+ TalkEndPoint int `xml:"talkEndPoint"`
+}
+
+func NewRDCutAddFromXML(data io.Reader) (cut *RDCutAdd, err error) {
+ decoder := xml.NewDecoder(data)
+ cut = &RDCutAdd{}
+ if xmlerr := decoder.Decode(cut); xmlerr != nil {
+ err = fmt.Errorf("Error parsing XML response: %s", xmlerr)
+ return
+ }
+ return
+}