summaryrefslogtreecommitdiff
path: root/src/pool-import
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-09-22 17:00:12 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-09-22 17:00:12 (GMT)
commitaca21335f9ec65f7d3a19a7a0546a897ab84a488 (patch)
tree1c7aaf530517d301edc845a3338d8b23cc897575 /src/pool-import
parent5b86fbac4267f9ea6f9ae58d0adb2331cbdafa7c (diff)
strip C0 control characters from old DBpool-sync
Diffstat (limited to 'src/pool-import')
-rw-r--r--src/pool-import/main.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/pool-import/main.go b/src/pool-import/main.go
index 7de3b55..85dd811 100644
--- a/src/pool-import/main.go
+++ b/src/pool-import/main.go
@@ -28,8 +28,10 @@ import (
"os"
"os/signal"
"sort"
+ "strings"
"syscall"
"time"
+ "unicode"
"code.helsinki.at/rhrd-go/rddb"
"code.helsinki.at/rhrd-go/rhimport"
@@ -46,6 +48,16 @@ func Done(res rhimport.Result, userdata interface{}) bool {
return true
}
+func stripControlCodes(in string) string {
+ isC0 := func(r rune) rune {
+ if uint32(r) <= unicode.MaxLatin1 && uint8(r) <= 0x1F {
+ return -1
+ }
+ return r
+ }
+ return strings.Map(isC0, in)
+}
+
func HandleCart(cart uint, cut uint, artist, album, title, dstgroup string, sessions *rhimport.SessionStore, conf *rhimport.Config, stdlog, dbglog *log.Logger, c <-chan os.Signal) int {
filename := fmt.Sprintf("%06d_%03d.wav", cart, cut)
@@ -58,9 +70,9 @@ func HandleCart(cart uint, cut uint, artist, album, title, dstgroup string, sess
ctx.GroupName = dstgroup
ctx.SourceUri = "local:///" + filename
ctx.FetchConverter = "ffmpeg-bs1770"
- ctx.ExtraMetaData["ARTIST"] = artist
- ctx.ExtraMetaData["ALBUM"] = album
- ctx.ExtraMetaData["TITLE"] = title
+ ctx.ExtraMetaData["ARTIST"] = stripControlCodes(artist)
+ ctx.ExtraMetaData["ALBUM"] = stripControlCodes(album)
+ ctx.ExtraMetaData["TITLE"] = stripControlCodes(title)
_, s, code, errstring := sessions.New(ctx, "")
if code != http.StatusOK {