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 7f6c34a0 authored by Christof Gerber's avatar Christof Gerber
Browse files

Introduce ErrYoutubeVideoUnavailable

parent 6af840c7
Pipeline #35288 passed with stages
in 5 minutes and 4 seconds
......@@ -12,8 +12,8 @@ require (
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 // indirect
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 // indirect
golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e // indirect
golang.org/x/sys v0.0.0-20190528183647-3626398d7749 // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20190525145741-7be61e1b0e51 // indirect
golang.org/x/tools v0.0.0-20190529010454-aa71c3f32488 // indirect
google.golang.org/api v0.3.2
)
......@@ -132,6 +132,8 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e h1:Pzdi8HRppinixnWWzN6KSa0QkBM+GKsTJaWwwfJskNw=
golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190528183647-3626398d7749 h1:oG2HS+e2B9VqK95y67B5MgJIJhOPY27/m5uJKJhHzus=
golang.org/x/sys v0.0.0-20190528183647-3626398d7749/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
......@@ -144,6 +146,8 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190525145741-7be61e1b0e51 h1:RhYYBLDB5MoVkvoNGMNk+DSj7WoGhySvIvtEjTyiP74=
golang.org/x/tools v0.0.0-20190525145741-7be61e1b0e51/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190529010454-aa71c3f32488 h1:vBgi/AgEje1rNScpWGJqe+RPHHZvBqrk9UH+LOXWN6Q=
golang.org/x/tools v0.0.0-20190529010454-aa71c3f32488/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
google.golang.org/api v0.3.2 h1:iTp+3yyl/KOtxa/d1/JUE0GGSoR6FuW5udver22iwpw=
google.golang.org/api v0.3.2/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
......
......@@ -54,6 +54,13 @@ func (e ErrYoutubeDLLangNotSupported) Error() string {
return string(e)
}
// ErrYoutubeVideoUnavailable is thrown when language not supported
type ErrYoutubeVideoUnavailable string
func (e ErrYoutubeVideoUnavailable) Error() string {
return string(e)
}
// ErrYoutubeDL are errors with related to the youtubedl pkg
type ErrYoutubeDL string
......@@ -66,11 +73,10 @@ func runYoutubeDL(args []string) (output []byte, err error) {
log.Debug(args)
output, err = cmd.CombinedOutput()
log.Trace(string(output))
if err != nil {
return nil, err
if err != nil && strings.Contains(string(output), "video is unavailable") {
return nil, ErrYoutubeVideoUnavailable(string(output))
}
return output, nil
return output, err
}
func getVideoInfo(id string) (info map[string]interface{}, err error) {
......@@ -116,9 +122,9 @@ func NewSubList() *SubList {
}
}
func listSubs(id string) (subs *SubList, err error) {
func listSubs(id string) (*SubList, error) {
subs = NewSubList()
subs := NewSubList()
args := []string{
"--skip-download",
......
......@@ -129,3 +129,8 @@ func TestGetSubtitle(t *testing.T) {
assert.Equal(t, nil, err)
assert.Equal(t, "Philosophers, dramatists, theologians", sub.Items[0].String())
}
func TestUnavailableVideo(t *testing.T) {
_, err := listSubs("vBc5vR5c_VE")
assert.IsType(t, ErrYoutubeVideoUnavailable(""), err)
}
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