summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimport/importer.go
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/rhimport/importer.go
parent3e15d6d3c032b3680071779471770ff0f5acb0ec (diff)
importer now knows which information is needed for what operation
uint vs int for some values
Diffstat (limited to 'src/helsinki.at/rhimport/importer.go')
-rw-r--r--src/helsinki.at/rhimport/importer.go51
1 files changed, 41 insertions, 10 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)