To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit e3ae2832 authored by Christof Gerber's avatar Christof Gerber
Browse files

dirty fix of youtube-dl warning in cmd output

parent 849caaa9
......@@ -54,7 +54,9 @@ func (e ErrYoutubeDL) Error() string {
func runYoutubeDL(args []string) (output []byte, err error) {
cmd := exec.Command("youtube-dl", args...)
log.Trace(args)
output, err = cmd.CombinedOutput()
log.Trace(string(output))
if err != nil {
return nil, err
}
......@@ -75,7 +77,13 @@ func getVideoInfo(id string) (info map[string]interface{}, err error) {
return info, err
}
err = json.Unmarshal(output, &info)
lines := strings.Split(strings.Trim(string(output), "\n\t "), "\n")
if len(lines) == 0 {
return nil, ErrYoutubeDL("youtube-dl response decoding error")
}
err = json.Unmarshal([]byte(lines[len(lines)-1]), &info)
if err != nil {
return info, err
}
......@@ -273,7 +281,7 @@ func GetVideoURL(id string) (video *url.URL, audio *url.URL, err error) {
// run command
//log.Println(args)
cmd := exec.Command("youtube-dl", args...)
out, err := cmd.CombinedOutput()
out, err := cmd.Output()
if err != nil {
return nil, nil, err
}
......
......@@ -11,8 +11,6 @@ import (
func TestGetPlaylistVideos(t *testing.T) {
log.SetLevel(log.TraceLevel)
videos, err := GetPlaylistVideos("PLpTJzCmGYaZFjE7jfH1tKFZt9rtqvvuj0", os.Getenv("YOUTUBE_DATA_API_KEY"))
assert.Equal(t, nil, err)
assert.Equal(t, 3, len(videos))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment