summaryrefslogtreecommitdiff
path: root/rhimport
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport')
-rw-r--r--rhimport/converter.go9
-rw-r--r--rhimport/fetcher.go16
2 files changed, 19 insertions, 6 deletions
diff --git a/rhimport/converter.go b/rhimport/converter.go
index a451e24..f48a041 100644
--- a/rhimport/converter.go
+++ b/rhimport/converter.go
@@ -26,6 +26,7 @@ package rhimport
import (
"errors"
+ "fmt"
"io"
"os"
"os/exec"
@@ -96,7 +97,13 @@ func NewFFMpegFetchConverter(filename string, metadata map[string]string) (ff *F
ext := filepath.Ext(filename)
filenameFlac = strings.TrimSuffix(filename, ext) + ".flac"
rhl.Printf("ffmpeg-converter: starting ffmpeg for file '%s' (had extension: '%s')", filenameFlac, ext)
- ff.cmd = exec.Command("ffmpeg", "-loglevel", "warning", "-i", "-", "-map_metadata", "0", "-f", "flac", filenameFlac)
+ ff.cmd = exec.Command("ffmpeg", "-loglevel", "warning", "-i", "-", "-map_metadata", "0")
+ if metadata != nil {
+ for key, value := range metadata {
+ ff.cmd.Args = append(ff.cmd.Args, "-metadata", fmt.Sprintf("%s=%q", key, value))
+ }
+ }
+ ff.cmd.Args = append(ff.cmd.Args, "-f", "flac", filenameFlac)
if ff.pipe, err = ff.cmd.StdinPipe(); err != nil {
return nil, "", err
}
diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go
index c2e4604..e4e03c9 100644
--- a/rhimport/fetcher.go
+++ b/rhimport/fetcher.go
@@ -48,6 +48,7 @@ type FetcherCurlCBData struct {
basepath string
filename string
remotename string
+ metadata map[string]string
conv FetchConverter
totalSize float64
written uint64
@@ -79,7 +80,7 @@ func curlWriteCallback(ptr []byte, userdata interface{}) bool {
}
data.filename = filepath.Join(data.basepath, name)
}
- conv, newFilename, err := NewFetchConverter(data.ctx.FetchConverter, data.filename, nil)
+ conv, newFilename, err := NewFetchConverter(data.ctx.FetchConverter, data.filename, data.metadata)
if err != nil {
rhl.Printf("Unable to create converter for file %s: %s", data.filename, err)
data.writeError = err
@@ -236,9 +237,7 @@ var weekdays = [...]string{
"Samstag",
}
-func generateArchivFilePath(uri *url.URL) (file, path string, err error) {
- var t time.Time
-
+func generateArchivFilePath(uri *url.URL) (file, path string, t time.Time, err error) {
if t, err = time.Parse("2006/01/02/15/04", fmt.Sprintf("%s%s", uri.Host, uri.Path)); err != nil {
return
}
@@ -253,11 +252,13 @@ func fetchFileArchiv(ctx *Context, res *Result, uri *url.URL) (err error) {
rhdl.Printf("archiv fetcher called for '%s'", ctx.SourceUri)
var srcfile, srcpath string
- if srcfile, srcpath, err = generateArchivFilePath(uri); err != nil {
+ var start time.Time
+ if srcfile, srcpath, start, err = generateArchivFilePath(uri); err != nil {
res.ResponseCode = http.StatusBadRequest
res.ErrorString = fmt.Sprintf("date/time is invalid: %s", err)
return nil
}
+ end := start.Add(time.Hour)
easy := curl.EasyInit()
if easy == nil {
@@ -291,6 +292,11 @@ func fetchFileArchiv(ctx *Context, res *Result, uri *url.URL) (err error) {
easy.Setopt(curl.OPT_BUFFERSIZE, 1024*1024)
+ cbdata.metadata = make(map[string]string)
+ cbdata.metadata["TITLE"] = fmt.Sprintf("Archiv vom %s - %s Uhr", start.Format("2.1.6 03:04"), end.Format("03:04"))
+ cbdata.metadata["ALBUM"] = "Radio Helsinki Archiv"
+ cbdata.metadata["ORGANIZATION"] = "Radio Helsinki"
+
rhdl.Printf("importing archiv file from %s", scpuri)
err = easy.Perform()
var convOut string