src/music/video.go (view raw)
1package music
2
3import (
4 "strings"
5
6 gl "github.com/BiRabittoh/disgord/src/globals"
7 "github.com/kkdai/youtube/v2"
8)
9
10func getVideo(args []string) (*youtube.Video, error) {
11 video, err := yt.GetVideo(args[0])
12 if err == nil {
13 return video, nil
14 }
15
16 if !strings.HasPrefix(err.Error(), "extractVideoID failed") {
17 return nil, err
18 }
19
20 id, err := gl.Search(args)
21 if err != nil || id == "" {
22 return nil, err
23 }
24
25 return yt.GetVideo(id)
26}