summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/helsinki.at/rhimport/conf.go12
-rw-r--r--src/helsinki.at/rhimport/importer.go10
-rw-r--r--src/helsinki.at/rhimport/rddb.go2
-rw-r--r--src/helsinki.at/rhimportd/ctrlWebSimple.go22
-rw-r--r--test/simple-show.json6
-rw-r--r--test/simple1.json2
-rw-r--r--test/simple2.json2
-rw-r--r--test/simple3.json2
-rw-r--r--test/simple4.json2
-rw-r--r--test/simple5.json2
10 files changed, 50 insertions, 12 deletions
diff --git a/src/helsinki.at/rhimport/conf.go b/src/helsinki.at/rhimport/conf.go
index 7288a89..2386ba9 100644
--- a/src/helsinki.at/rhimport/conf.go
+++ b/src/helsinki.at/rhimport/conf.go
@@ -28,6 +28,13 @@ import (
"github.com/vaughan0/go-ini"
)
+type ImportParamDefaults struct {
+ Channels uint
+ NormalizationLevel int
+ AutotrimLevel int
+ UseMetaData bool
+}
+
type Config struct {
configfile string
RDXportEndpoint string
@@ -36,6 +43,7 @@ type Config struct {
db_user string
db_passwd string
db_db string
+ ImportParamDefaults
}
func get_ini_value(file ini.File, section string, key string, dflt string) string {
@@ -67,5 +75,9 @@ func NewConfig(configfile, rdxport_endpoint, temp_dir *string) (conf *Config, er
}
conf.RDXportEndpoint = *rdxport_endpoint
conf.TempDir = *temp_dir
+ conf.ImportParamDefaults.Channels = 2
+ conf.ImportParamDefaults.NormalizationLevel = -12
+ conf.ImportParamDefaults.AutotrimLevel = 0
+ conf.ImportParamDefaults.UseMetaData = true
return
}
diff --git a/src/helsinki.at/rhimport/importer.go b/src/helsinki.at/rhimport/importer.go
index 925722e..aa5343d 100644
--- a/src/helsinki.at/rhimport/importer.go
+++ b/src/helsinki.at/rhimport/importer.go
@@ -74,10 +74,10 @@ func NewImportContext(conf *Config, rddb *RdDb, user string) *ImportContext {
ctx.GroupName = ""
ctx.Cart = 0
ctx.Cut = 0
- ctx.Channels = 2
- ctx.NormalizationLevel = -12
- ctx.AutotrimLevel = 0
- ctx.UseMetaData = false
+ ctx.Channels = conf.ImportParamDefaults.Channels
+ ctx.NormalizationLevel = conf.ImportParamDefaults.NormalizationLevel
+ ctx.AutotrimLevel = conf.ImportParamDefaults.AutotrimLevel
+ ctx.UseMetaData = conf.ImportParamDefaults.UseMetaData
ctx.SourceFile = ""
ctx.DeleteSourceFile = false
ctx.DeleteSourceDir = false
@@ -158,6 +158,7 @@ func (ctx *ImportContext) getShowInfo() (carts []uint, err error) {
ctx.GroupName = res.group
ctx.NormalizationLevel = res.norm_lvl
ctx.AutotrimLevel = res.trim_lvl
+ ctx.Channels = 2
ctx.UseMetaData = true
carts = res.carts
return
@@ -188,6 +189,7 @@ func (ctx *ImportContext) getMusicInfo() (err error) {
}
ctx.NormalizationLevel = res.norm_lvl
ctx.AutotrimLevel = res.trim_lvl
+ ctx.Channels = 2
ctx.UseMetaData = true
return
}
diff --git a/src/helsinki.at/rhimport/rddb.go b/src/helsinki.at/rhimport/rddb.go
index b693c47..8b72f58 100644
--- a/src/helsinki.at/rhimport/rddb.go
+++ b/src/helsinki.at/rhimport/rddb.go
@@ -251,7 +251,7 @@ func (self *RdDb) getMusicInfo(group string) (result getMusicInfoResult) {
result.err = self.checkMusicGroupStmt.QueryRow(group).Scan(&result.norm_lvl, &result.trim_lvl)
if result.err != nil {
if result.err == sql.ErrNoRows {
- result.err = fmt.Errorf("music pool '%d' not found", group)
+ result.err = fmt.Errorf("music pool '%s' not found", group)
}
return
}
diff --git a/src/helsinki.at/rhimportd/ctrlWebSimple.go b/src/helsinki.at/rhimportd/ctrlWebSimple.go
index 5be760c..41e4f81 100644
--- a/src/helsinki.at/rhimportd/ctrlWebSimple.go
+++ b/src/helsinki.at/rhimportd/ctrlWebSimple.go
@@ -48,6 +48,24 @@ type webSimpleRequestData struct {
SourceUri string `json:"SOURCE_URI"`
}
+func newWebSimpleRequestData(conf *rhimport.Config) *webSimpleRequestData {
+ rd := new(webSimpleRequestData)
+ rd.UserName = ""
+ rd.Password = ""
+ rd.ShowId = 0
+ rd.ClearShowCarts = false
+ rd.MusicPoolGroup = ""
+ rd.Cart = 0
+ rd.Cut = 0
+ rd.Channels = conf.ImportParamDefaults.Channels
+ rd.NormalizationLevel = conf.ImportParamDefaults.NormalizationLevel
+ rd.AutotrimLevel = conf.ImportParamDefaults.AutotrimLevel
+ rd.UseMetaData = conf.ImportParamDefaults.UseMetaData
+ rd.SourceUri = ""
+
+ return rd
+}
+
type webSimpleResponseData struct {
ResponseCode int `json:"REPONSE_CODE"`
ErrorString string `json:"ERROR_STRING"`
@@ -78,8 +96,8 @@ func webSimpleProgressCallback(step int, step_name string, progress float64, use
func webSimpleParseRequest(conf *rhimport.Config, rddb *rhimport.RdDb, trusted bool, r *http.Request) (ctx *rhimport.ImportContext, err error) {
decoder := json.NewDecoder(r.Body)
- var reqdata webSimpleRequestData
- if jsonerr := decoder.Decode(&reqdata); jsonerr != nil {
+ reqdata := newWebSimpleRequestData(conf)
+ if jsonerr := decoder.Decode(reqdata); jsonerr != nil {
err = fmt.Errorf("Error parsing JSON response: %s", jsonerr)
return
}
diff --git a/test/simple-show.json b/test/simple-show.json
new file mode 100644
index 0000000..f7f64a5
--- /dev/null
+++ b/test/simple-show.json
@@ -0,0 +1,6 @@
+{
+ "LOGIN_NAME": "heslinki",
+ "PASSWORD": "123456",
+ "SHOW_ID": 10000,
+ "SOURCE_URI": "http://www.tonycuffe.com/mp3/tail%20toddle.mp3"
+}
diff --git a/test/simple1.json b/test/simple1.json
index edd70b4..84748ec 100644
--- a/test/simple1.json
+++ b/test/simple1.json
@@ -3,7 +3,7 @@
"PASSWORD": "123456",
"CART_NUMBER": 100000,
"CHANNELS": 2,
- "NORMALIZATION_LEVEL": -1200,
+ "NORMALIZATION_LEVEL": -12,
"AUTOTRIM_LEVEL": 0,
"USE_METADATA": true,
"SOURCE_URI": "http://www.tonycuffe.com/mp3/tail%20toddle.mp3"
diff --git a/test/simple2.json b/test/simple2.json
index 194bba3..085e050 100644
--- a/test/simple2.json
+++ b/test/simple2.json
@@ -3,7 +3,7 @@
"PASSWORD": "123456",
"CART_NUMBER": 100000,
"CHANNELS": 2,
- "NORMALIZATION_LEVEL": -1200,
+ "NORMALIZATION_LEVEL": -12,
"AUTOTRIM_LEVEL": 0,
"USE_METADATA": true,
"SOURCE_URI": "local:///path/to/sendung.mp3"
diff --git a/test/simple3.json b/test/simple3.json
index a378b1b..a43c43e 100644
--- a/test/simple3.json
+++ b/test/simple3.json
@@ -3,7 +3,7 @@
"PASSWORD": "123456",
"CART_NUMBER": 100000,
"CHANNELS": 2,
- "NORMALIZATION_LEVEL": -1200,
+ "NORMALIZATION_LEVEL": -12,
"AUTOTRIM_LEVEL": 0,
"USE_METADATA": true,
"SOURCE_URI": "http://www.jtricks.com/download-unknown"
diff --git a/test/simple4.json b/test/simple4.json
index 7bf5b41..12071fd 100644
--- a/test/simple4.json
+++ b/test/simple4.json
@@ -3,7 +3,7 @@
"PASSWORD": "123456",
"CART_NUMBER": 100000,
"CHANNELS": 2,
- "NORMALIZATION_LEVEL": -1200,
+ "NORMALIZATION_LEVEL": -12,
"AUTOTRIM_LEVEL": 0,
"USE_METADATA": true,
"SOURCE_URI": "local:///home/equinox/helsinki/rivenhell/contrib/rhimportd/test/empty.mp3"
diff --git a/test/simple5.json b/test/simple5.json
index 811d210..e858bc4 100644
--- a/test/simple5.json
+++ b/test/simple5.json
@@ -3,7 +3,7 @@
"PASSWORD": "123456",
"CART_NUMBER": 100000,
"CHANNELS": 2,
- "NORMALIZATION_LEVEL": -1200,
+ "NORMALIZATION_LEVEL": -12,
"AUTOTRIM_LEVEL": 0,
"USE_METADATA": true,
"SOURCE_URI": "local:///home/equinox/helsinki/rivenhell/contrib/rhimportd/test/silence1s.wav"