summaryrefslogtreecommitdiff
path: root/src/helsinki.at
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-12 04:02:12 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-12 04:02:12 (GMT)
commitdc915f7519a166c4cab5128593894ff368b77ac8 (patch)
treece4cb76b323d85f3028a68003bc71da0350b7d3f /src/helsinki.at
parent3e15d6d3c032b3680071779471770ff0f5acb0ec (diff)
importer now knows which information is needed for what operation
uint vs int for some values
Diffstat (limited to 'src/helsinki.at')
-rw-r--r--src/helsinki.at/rhimport/importer.go51
-rw-r--r--src/helsinki.at/rhimport/rdxport_responses.go20
-rw-r--r--src/helsinki.at/rhimportd/ctrlWebSimple.go6
3 files changed, 54 insertions, 23 deletions
diff --git a/src/helsinki.at/rhimport/importer.go b/src/helsinki.at/rhimport/importer.go
index 505fffd..f365ea5 100644
--- a/src/helsinki.at/rhimport/importer.go
+++ b/src/helsinki.at/rhimport/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/src/helsinki.at/rhimport/rdxport_responses.go b/src/helsinki.at/rhimport/rdxport_responses.go
index db309d9..392f58f 100644
--- a/src/helsinki.at/rhimport/rdxport_responses.go
+++ b/src/helsinki.at/rhimport/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"`
diff --git a/src/helsinki.at/rhimportd/ctrlWebSimple.go b/src/helsinki.at/rhimportd/ctrlWebSimple.go
index 9b25dad..3f9c48d 100644
--- a/src/helsinki.at/rhimportd/ctrlWebSimple.go
+++ b/src/helsinki.at/rhimportd/ctrlWebSimple.go
@@ -37,9 +37,9 @@ type webSimpleRequestData struct {
UserName string `json:"LOGIN_NAME"`
Password string `json:"PASSWORD"`
GroupName string `json:"GROUP_NAME"`
- Cart int `json:"CART_NUMBER"`
- Cut int `json:"CUT_NUMBER"`
- Channels int `json:"CHANNELS"`
+ Cart uint `json:"CART_NUMBER"`
+ Cut uint `json:"CUT_NUMBER"`
+ Channels uint `json:"CHANNELS"`
NormalizationLevel int `json:"NORMALIZATION_LEVEL"`
AutotrimLevel int `json:"AUTOTRIM_LEVEL"`
UseMetaData bool `json:"USE_METADATA"`