From 8816d31e40ad06f2c634574cf6afbbef11ddbb95 Mon Sep 17 00:00:00 2001
From: Christian Pointner <equinox@helsinki.at>
Date: Wed, 13 Jul 2016 23:50:05 +0200
Subject: added normalization step


diff --git a/src/rhimportd/ctrlTelnet.go b/src/rhimportd/ctrlTelnet.go
index fa0ce65..4177128 100644
--- a/src/rhimportd/ctrlTelnet.go
+++ b/src/rhimportd/ctrlTelnet.go
@@ -59,7 +59,8 @@ func telnetHelp(c *telgo.Client, args []string, conf *rhimport.Config, db *rddb.
 			c.Sayln("    Password             string   password to use for rdxport interface")
 			c.Sayln("    SourceUri            string   uri to the file to import")
 			c.Sayln("    SourceFilePolicy     enum     one of: auto, keep, delete, delete-with-dir")
-			c.Sayln("    FetchConverter       string   fetch converter to use (one of null, ffmpeg)")
+			c.Sayln("    FetchConverter       string   fetch converter to use")
+			c.Sayln("                                  (one of: null, ffmpeg, bs1770, ffmpeg-bs1770)")
 			c.Sayln("    ShowId               uint     the RHRD show id to import to")
 			c.Sayln("    ClearShowCarts       bool     clear all show-carts before importing?")
 			c.Sayln("    GroupName            string   name of music-pool group to import to")
@@ -294,6 +295,13 @@ func telnetRun(c *telgo.Client, args []string, conf *rhimport.Config, db *rddb.D
 	}
 
 	c.Sayln("")
+	c.Sayln("normalizing file '%s'", ctx.SourceFile)
+	if err := rhimport.NormalizeFile(ctx); err != nil {
+		c.Sayln("normalize file error: %s", err)
+		return false
+	}
+
+	c.Sayln("")
 	c.Sayln("importing file '%s'", ctx.SourceFile)
 	if res, err := rhimport.ImportFile(ctx); err != nil {
 		c.Sayln("")
diff --git a/src/rhimportd/ctrlWatchDir.go b/src/rhimportd/ctrlWatchDir.go
index 6985a74..7b185c0 100644
--- a/src/rhimportd/ctrlWatchDir.go
+++ b/src/rhimportd/ctrlWatchDir.go
@@ -149,6 +149,11 @@ func watchDirHandler(conf *rhimport.Config, db *rddb.DBChan, ctx *rhimport.Conte
 		return
 	}
 
+	if err = rhimport.NormalizeFile(ctx); err != nil {
+		watchDirErrorResponse(filename, http.StatusInternalServerError, err.Error(), "")
+		return
+	}
+
 	if res, err = rhimport.ImportFile(ctx); err != nil {
 		watchDirErrorResponse(filename, http.StatusInternalServerError, err.Error(), res.SourceFile)
 		return
diff --git a/src/rhimportd/ctrlWebSimple.go b/src/rhimportd/ctrlWebSimple.go
index 05bbb4d..e690571 100644
--- a/src/rhimportd/ctrlWebSimple.go
+++ b/src/rhimportd/ctrlWebSimple.go
@@ -147,6 +147,11 @@ func webSimpleHandler(conf *rhimport.Config, db *rddb.DBChan, sessions *rhimport
 		return
 	}
 
+	if err = rhimport.NormalizeFile(ctx); err != nil {
+		webSimpleErrorResponse(w, http.StatusInternalServerError, err.Error())
+		return
+	}
+
 	if res, err = rhimport.ImportFile(ctx); err != nil {
 		webSimpleErrorResponse(w, http.StatusInternalServerError, err.Error())
 		return
-- 
cgit v0.10.2