summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimport/importer.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-04 00:26:12 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-04 00:26:12 (GMT)
commit80c19f00f3b098621fe5bb8f42c009f2890e84f8 (patch)
treeaedaa9ff503802941c4539f8a2d9d1b4a5a1115a /src/helsinki.at/rhimport/importer.go
parentece69efd67af2982cac882b9192872c7ff6957bb (diff)
introduced conf
Diffstat (limited to 'src/helsinki.at/rhimport/importer.go')
-rw-r--r--src/helsinki.at/rhimport/importer.go63
1 files changed, 52 insertions, 11 deletions
diff --git a/src/helsinki.at/rhimport/importer.go b/src/helsinki.at/rhimport/importer.go
index 5da6075..8c7e66e 100644
--- a/src/helsinki.at/rhimport/importer.go
+++ b/src/helsinki.at/rhimport/importer.go
@@ -34,16 +34,49 @@ import (
)
type ImportContext struct {
- username string
- groupname string
- // TODO: password channel
- cart int
- channels int
- normalization_level int
- autotrim_level int
- use_meta_data bool
- source_file string
- delete_source_file bool
+ Conf *Config
+ UserName string
+ password string
+ GroupName string
+ Cart int
+ Channels int
+ NormalizationLevel int
+ AutotrimLevel int
+ UseMetaData bool
+ SourceFile string
+ DeleteSourceFile bool
+}
+
+func NewImportContext(conf *Config, user string, group string, cart int) *ImportContext {
+ ctx := new(ImportContext)
+ ctx.Conf = conf
+ ctx.UserName = user
+ ctx.GroupName = group
+ ctx.Cart = cart
+ ctx.Channels = 2
+ ctx.NormalizationLevel = 1200
+ ctx.AutotrimLevel = 0
+ ctx.UseMetaData = false
+ ctx.SourceFile = ""
+ ctx.DeleteSourceFile = false
+
+ return ctx
+}
+
+func (ctx *ImportContext) getPassword(cached bool) (err error) {
+ req := getPasswordRequest{}
+ req.username = ctx.UserName
+ req.cached = cached
+ req.response = make(chan getPasswordResult)
+ ctx.Conf.getPasswordChan <- req
+
+ res := <-req.response
+ if res.err != nil {
+ err = res.err
+ return
+ }
+ ctx.password = res.password
+ return
}
// func import_audio(url, file string) (err error) {
@@ -94,6 +127,14 @@ type ImportContext struct {
// }
func ImportFile(ctx *ImportContext) (err error) {
- err = fmt.Errorf("not yet implemented")
+ rhl.Println("ImportFile called for", ctx.SourceFile)
+
+ if err = ctx.getPassword(true); err != nil {
+ return
+ }
+ rhdl.Println("credentials:", ctx.UserName, "/", ctx.password)
+
+ err = fmt.Errorf("%+v", ctx)
+
return
}