/
youtube.go
61 lines (48 loc) 路 1.16 KB
/
youtube.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package radio
import (
"log/slog"
"github.com/lmittmann/tint"
"github.com/pauloo27/aryzona/internal/discord/voicer/playable"
"github.com/pauloo27/aryzona/internal/providers/youtube"
)
type YouTubeRadio struct {
BaseRadio
ID, Name, URL string
}
var _ RadioChannel = &YouTubeRadio{}
func newYouTubeRadio(id, name, url string) RadioChannel {
return YouTubeRadio{
ID: id,
Name: name,
URL: url,
BaseRadio: BaseRadio{},
}
}
func (r YouTubeRadio) GetID() string {
return r.ID
}
func (r YouTubeRadio) GetName() string {
return r.Name
}
func (r YouTubeRadio) GetShareURL() string {
return r.GetPlayable().GetShareURL()
}
func (r YouTubeRadio) GetThumbnailURL() (string, error) {
return "", nil
}
func (r YouTubeRadio) IsOpus() bool {
return r.GetPlayable().IsOpus()
}
func (r YouTubeRadio) GetDirectURL() (string, error) {
return r.GetPlayable().GetDirectURL()
}
func (r YouTubeRadio) GetFullTitle() (title, artist string) {
return r.GetPlayable().GetFullTitle()
}
func (r YouTubeRadio) GetPlayable() playable.Playable {
vid, err := youtube.GetVideo(r.URL)
if err != nil {
slog.Error("Error getting video", tint.Err(err))
}
return vid
}