Skip to content

Commit 3371eeb

Browse files
Maximilian BruneMaximilian Brune
authored andcommitted
youtube-dl is now neccesary for playing youtube videos
1 parent d1194f2 commit 3371eeb

3 files changed

Lines changed: 5 additions & 17 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mumble library written in go. Intended for writing client side music bots.
88
- If you don't want to study the entire Code in order to find out what you can do with this library and how, I made a README.md file in most folder explaining what each .go source file does. Furthermore the README file in the gomble directory shows a little illustration (sequence diagram) written in plantuml on how it works.
99

1010
## Features
11-
- you can play youtube videos ~~(without any additional dependency)~~ (it's now recommended to have youtube-dl installed)
11+
- you can play youtube videos ~~(without any additional dependency)~~ (for playing youtube-videos it is now necessary to have youtube-dl installed)
1212
- it automatically uses UDP for sending audio data
1313
- Buffering, so no disruptions in hearing "should" occur
1414
- Stereo sound (since mumble 1.4 or newer)

gomble/track.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ func LoadTrack(url string) (*Track, error) {
4343
src, err = youtube.NewYoutubedlVideo(surl)
4444
} else {
4545
// otherwise use native youtube stream implementation (probably doesn't work, but worth a try)
46-
src, err = youtube.NewYoutubeVideo(surl)
46+
// src, err = youtube.NewYoutubeVideo(surl)
47+
logger.Fatalf("No Youtube-dl installed. exiting\n")
4748
}
4849
if err != nil {
4950
return nil, err

main.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"regexp"
54
"strings"
65

76
"github.com/CodingVoid/gomble/gomble"
@@ -34,20 +33,8 @@ func OnChannelMessageReceived(e gomble.ChannelMessageReceivedEvent) {
3433
// set current channel
3534
currentChannel = gomble.GetChannel(e.Channel)
3635
if strings.HasPrefix(e.Message, "#play ") {
37-
var url string
38-
fields := strings.Fields(e.Message)
39-
if fields[1] == "<a" {
40-
// there is an html encoded link
41-
// <a href=link>link</a>
42-
re := regexp.MustCompile(`https://www.youtube.com/watch\?v=[a-zA-Z0-9\-\_]+`) // need to use ` character otherwise \character are recognized as escape characters
43-
matches := re.FindStringSubmatch(e.Message)
44-
url = matches[0]
45-
} else {
46-
// probably not html encoded (maybe allowHTML is off?)
47-
url = strings.Fields(e.Message)[1]
48-
}
49-
logger.Debugf(url + "\n")
50-
yt, err := gomble.LoadTrack(url)
36+
logger.Debugf(e.Message + "\n")
37+
yt, err := gomble.LoadTrack(e.Message)
5138
if err != nil {
5239
logger.Errorf("%v", err)
5340
return

0 commit comments

Comments
 (0)