summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimport/importer.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-07 16:22:51 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-08 00:34:58 (GMT)
commitabff4760fe4aede34b60fbefc8f398ad2370304e (patch)
tree5bc6c555d7269e4fce0f365478a9348b2a4fb7e6 /src/helsinki.at/rhimport/importer.go
parenta1b290f026011276f9c16f6af390a2aceb2f9ccc (diff)
renamed RDDB to RdDb and added code to fetch show infos based on ID
Diffstat (limited to 'src/helsinki.at/rhimport/importer.go')
-rw-r--r--src/helsinki.at/rhimport/importer.go30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/helsinki.at/rhimport/importer.go b/src/helsinki.at/rhimport/importer.go
index 5eea054..2b512ed 100644
--- a/src/helsinki.at/rhimport/importer.go
+++ b/src/helsinki.at/rhimport/importer.go
@@ -35,10 +35,11 @@ import (
type ImportContext struct {
*Config
- *RDDB
+ *RdDb
UserName string
Password string
Trusted bool
+ ShowId int
GroupName string
Cart int
Cut int
@@ -51,13 +52,14 @@ type ImportContext struct {
DeleteSourceFile bool
}
-func NewImportContext(conf *Config, rddb *RDDB, user string, group string) *ImportContext {
+func NewImportContext(conf *Config, rddb *RdDb, user string, group string) *ImportContext {
ctx := new(ImportContext)
ctx.Config = conf
- ctx.RDDB = rddb
+ ctx.RdDb = rddb
ctx.UserName = user
ctx.Password = ""
ctx.Trusted = false
+ ctx.ShowId = 0
ctx.GroupName = group
ctx.Cart = 0
ctx.Cut = 0
@@ -76,7 +78,7 @@ func (ctx *ImportContext) getPassword(cached bool) (err error) {
req.username = ctx.UserName
req.cached = cached
req.response = make(chan getPasswordResult)
- ctx.RDDB.getPasswordChan <- req
+ ctx.RdDb.getPasswordChan <- req
res := <-req.response
if res.err != nil {
@@ -87,6 +89,21 @@ func (ctx *ImportContext) getPassword(cached bool) (err error) {
return
}
+func (ctx *ImportContext) getShowInfo() (err error) {
+ req := getShowInfoRequest{}
+ req.showid = ctx.ShowId
+ req.response = make(chan getShowInfoResult)
+ ctx.RdDb.getShowInfoChan <- req
+
+ res := <-req.response
+ if res.err != nil {
+ err = res.err
+ return
+ }
+ rhdl.Printf("Title of show %d is '%s'", ctx.ShowId, res.title)
+ return
+}
+
// func import_audio(url, file string) (err error) {
// var b bytes.Buffer
@@ -142,6 +159,11 @@ func ImportFile(ctx *ImportContext) (err error) {
return
}
}
+
+ if err = ctx.getShowInfo(); err != nil {
+ return
+ }
+
rhdl.Printf("%+v", ctx)
return