summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--importer.go51
-rw-r--r--rdxport_responses.go20
2 files changed, 51 insertions, 20 deletions
diff --git a/importer.go b/importer.go
index 505fffd..f365ea5 100644
--- a/importer.go
+++ b/importer.go
@@ -46,10 +46,11 @@ type ImportContext struct {
Password string
Trusted bool
ShowId int
+ ClearShowCarts bool
GroupName string
- Cart int
- Cut int
- Channels int
+ Cart uint
+ Cut uint
+ Channels uint
NormalizationLevel int
AutotrimLevel int
UseMetaData bool
@@ -69,6 +70,7 @@ func NewImportContext(conf *Config, rddb *RdDb, user string, group string) *Impo
ctx.Password = ""
ctx.Trusted = false
ctx.ShowId = 0
+ ctx.ClearShowCarts = false
ctx.GroupName = group
ctx.Cart = 0
ctx.Cut = 0
@@ -118,8 +120,8 @@ func (ctx *ImportContext) getShowInfo() (err error) {
type ImportResult struct {
ResponseCode int
ErrorString string
- Cart int
- Cut int
+ Cart uint
+ Cut uint
}
func (self *ImportResult) fromRDWebResult(rdres *RDWebResult) {
@@ -397,11 +399,40 @@ func ImportFile(ctx *ImportContext) (res *ImportResult, err error) {
}
res = &ImportResult{}
- if err = import_audio(ctx, res); err != nil {
- return
- }
- if ctx.ProgressCallBack != nil {
- ctx.ProgressCallBack(2, "importing", 1.0, ctx.ProgressCallBackData)
+ if ctx.ShowId != 0 {
+ res.ResponseCode = 500
+ res.ErrorString = "Importing to shows using the show-id is not yet implemented"
+ // TODO: fetch info from dropboxes (cartlist, groupname, import-params)
+ // - if (ClearShowCarts == true): foreach(cart in cartlist): remove_cart(cart) [200 || 404 -> OK]
+ // - ctx.cart = 0
+ // - add_cart(ctx, res) [200 -> OK]
+ // - add_cut(ctx, res) [200 -> OK]
+ // - import_audio(ctx, res) [200 -> OK]
+ return
+ } else if ctx.GroupName != "" && ctx.Cart == 0 {
+ res.ResponseCode = 500
+ res.ErrorString = "Importing to music pools using the group name is not yet implemented"
+ // TODO: fetch info from dropboxes (import-params)
+ // - add_cart(ctx, res) [200 -> OK]
+ // - add_cut(ctx, res) [200 -> OK]
+ // - import_audio(ctx, res) [200 -> OK]
+ } else if ctx.Cart != 0 && ctx.Cut == 0 {
+ res.ResponseCode = 500
+ res.ErrorString = "Importing to a Cart which might not exist is not yet implemented"
+ // TODO: (everything except Cut and ShowId must be in context)
+ // - remove_cart(ctx, res) [200 || 404 -> OK]
+ // - add_cart(ctx, res) [200 -> OK]
+ // - add_cut(ctx, res) [200 -> OK]
+ // - import_audio(ctx, res) [200 -> OK]
+ } else if ctx.Cart != 0 && ctx.Cut != 0 {
+ if err = import_audio(ctx, res); err != nil {
+ return
+ }
+ res.Cart = ctx.Cart
+ res.Cut = ctx.Cut
+ } else {
+ res.ResponseCode = http.StatusBadRequest
+ res.ErrorString = "The request doesn't contain enough Information to be processed"
}
rhdl.Printf("ImportResult: %+v\n", res)
diff --git a/rdxport_responses.go b/rdxport_responses.go
index db309d9..392f58f 100644
--- a/rdxport_responses.go
+++ b/rdxport_responses.go
@@ -51,7 +51,7 @@ type RDCartAdd struct {
}
type RDCart struct {
- Number int `xml:"number"`
+ Number uint `xml:"number"`
Type string `xml:"type"`
GroupName string `xml:"groupName"`
Title string `xml:"title"`
@@ -64,15 +64,15 @@ type RDCart struct {
Publisher string `xml:"publisher"`
Composer string `xml:"composer"`
UserDefined string `xml:"userDefined"`
- UsageCode int `xml:"usageCode"`
+ UsageCode uint `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"`
+ CutQuantity uint `xml:"cutQuantity"`
+ LastCutPlayed uint `xml:"lastCutPlayed"`
+ Validity uint `xml:"validity"`
EnforceLength bool `xml:"enforceLength"`
Asynchronous bool `xml:"asyncronous"`
Owner string `xml:"owner"`
@@ -95,8 +95,8 @@ type RDCutAdd struct {
type RDCut struct {
Name string `xml:"cutName"`
- CartNumber int `xml:"cartNumber"`
- Number int `xml:"cutNumber"`
+ CartNumber uint `xml:"cartNumber"`
+ Number uint `xml:"cutNumber"`
EverGreen bool `xml:"evergreen"`
Description string `xml:"description"`
OutCue string `xml:"outcue"`
@@ -118,9 +118,9 @@ type RDCut struct {
OriginName string `xml:"originName"`
Weight int `xml:"weight"`
LastPlayDateTime string `xml:"lastPlayDatetime"`
- PlayCounter int `xml:"playCounter"`
- LocalCounter int `xml:"localCounter"`
- Validiy int `xml:"validity"`
+ PlayCounter uint `xml:"playCounter"`
+ LocalCounter uint `xml:"localCounter"`
+ Validiy uint `xml:"validity"`
CondingFormat int `xml:"codingFormat"`
SampleRate int `xml:"sampleRate"`
BitRate int `xml:"bitRate"`