2015-08-10 01:41:26 +02:00
|
|
|
package main
|
|
|
|
|
2015-08-10 01:42:41 +02:00
|
|
|
import (
|
2015-08-10 02:22:32 +02:00
|
|
|
"fmt"
|
2015-08-10 01:42:41 +02:00
|
|
|
"github.com/layeh/gumble/gumble"
|
2015-08-12 21:46:32 +02:00
|
|
|
"github.com/layeh/gumble/gumbleutil"
|
2015-08-12 22:22:55 +02:00
|
|
|
"os"
|
2015-08-10 20:29:58 +02:00
|
|
|
"time"
|
2015-08-10 01:42:41 +02:00
|
|
|
)
|
2015-08-10 01:41:26 +02:00
|
|
|
|
2015-08-12 20:52:38 +02:00
|
|
|
type TestSettings struct {
|
2015-08-12 21:31:12 +02:00
|
|
|
password string
|
|
|
|
ip string
|
|
|
|
port string
|
|
|
|
accesstokens []string
|
2015-08-12 20:49:03 +02:00
|
|
|
}
|
|
|
|
|
2015-08-12 20:52:38 +02:00
|
|
|
var test TestSettings
|
2015-08-12 20:49:03 +02:00
|
|
|
|
2015-08-12 21:34:32 +02:00
|
|
|
func Test(password, ip, port string, accesstokens []string) {
|
2015-08-12 20:52:38 +02:00
|
|
|
test = TestSettings{
|
2015-08-12 21:31:12 +02:00
|
|
|
password: password,
|
|
|
|
ip: ip,
|
|
|
|
port: port,
|
2015-08-12 21:34:32 +02:00
|
|
|
accesstokens: accesstokens,
|
2015-08-12 20:49:03 +02:00
|
|
|
}
|
2015-08-12 21:26:27 +02:00
|
|
|
test.testYoutubeSong()
|
2015-08-10 02:19:27 +02:00
|
|
|
}
|
|
|
|
|
2015-08-12 20:52:38 +02:00
|
|
|
func (t TestSettings) createClient(uname string) *gumble.Client {
|
2015-08-15 17:03:24 +02:00
|
|
|
config := gumble.Config{
|
2015-08-10 01:41:26 +02:00
|
|
|
Username: uname,
|
2015-08-12 20:49:03 +02:00
|
|
|
Password: t.password,
|
2015-08-12 21:31:12 +02:00
|
|
|
Address: t.ip + ":" + t.port,
|
|
|
|
Tokens: t.accesstokens,
|
2015-08-15 17:03:24 +02:00
|
|
|
}
|
|
|
|
config.TLSConfig.InsecureSkipVerify = true
|
|
|
|
client := gumble.NewClient(&config)
|
2015-08-12 21:46:32 +02:00
|
|
|
return client
|
2015-08-10 01:41:26 +02:00
|
|
|
}
|
|
|
|
|
2015-08-12 20:52:38 +02:00
|
|
|
func (t TestSettings) testYoutubeSong() {
|
2015-08-15 16:57:55 +02:00
|
|
|
dummyClient := t.createClient("dummy")
|
|
|
|
if err := dummyClient.Connect(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2015-08-12 23:06:03 +02:00
|
|
|
|
2015-08-12 23:01:34 +02:00
|
|
|
dj.client.Request(gumble.RequestUserList)
|
2015-08-12 23:06:03 +02:00
|
|
|
time.Sleep(time.Second * 5)
|
2015-08-15 16:57:55 +02:00
|
|
|
dummyUser := dj.client.Users.Find("dummy")
|
2015-08-12 22:28:54 +02:00
|
|
|
if dummyUser == nil {
|
2015-08-12 22:51:47 +02:00
|
|
|
fmt.Printf("User does not exist, printing users\n")
|
|
|
|
for _, user := range dj.client.Users {
|
|
|
|
fmt.Printf(user.Name + "\n")
|
|
|
|
}
|
|
|
|
fmt.Printf("End of user list\n")
|
2015-08-12 22:22:55 +02:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
2015-08-10 01:41:26 +02:00
|
|
|
|
|
|
|
// Don't judge, I used the (autogenerated) Top Tracks for United Kingdom playlist
|
|
|
|
songs := map[string]string{
|
|
|
|
"http://www.youtube.com/watch?v=QcIy9NiNbmo": "Taylor Swift - Bad Blood ft. Kendrick Lamar",
|
|
|
|
"https://www.youtube.com/watch?v=vjW8wmF5VWc": "Silentó - Watch Me (Whip/Nae Nae) (Official)",
|
|
|
|
"http://youtu.be/nsDwItoNlLc": "Tinie Tempah ft. Jess Glynne - Not Letting Go (Official Video)",
|
|
|
|
"https://youtu.be/hXTAn4ELEwM": "Years & Years - Shine",
|
|
|
|
"http://youtube.com/watch?v=RgKAFK5djSk": "Wiz Khalifa - See You Again ft. Charlie Puth [Official Video] Furious 7 Soundtrack",
|
|
|
|
"https://youtube.com/watch?v=qWWSM3wCiKY": "Calvin Harris & Disciples - How Deep Is Your Love (Audio)",
|
|
|
|
"http://www.youtube.com/v/yzTuBuRdAyA": "The Weeknd - The Hills",
|
|
|
|
"https://www.youtube.com/v/cNw8A5pwbVI": "Pia Mia - Do It Again ft. Chris Brown, Tyga",
|
|
|
|
}
|
|
|
|
|
|
|
|
for url, title := range songs {
|
2015-08-10 01:57:08 +02:00
|
|
|
err := add(dummyUser, url)
|
2015-08-10 01:41:26 +02:00
|
|
|
if err != nil {
|
2015-08-12 23:18:22 +02:00
|
|
|
fmt.Printf("For: %s; Expected: %s; Got: %s\n", url, title, err.Error())
|
2015-08-10 01:41:26 +02:00
|
|
|
} else if dj.queue.CurrentSong().Title() != title {
|
2015-08-12 23:18:22 +02:00
|
|
|
fmt.Printf("For: %s; Expected: %s; Got: %s\n", url, title, dj.queue.CurrentSong().Title())
|
2015-08-10 01:41:26 +02:00
|
|
|
}
|
2015-08-10 20:29:58 +02:00
|
|
|
|
2015-08-15 16:57:55 +02:00
|
|
|
time.Sleep(time.Second * 10)
|
2015-08-10 01:57:08 +02:00
|
|
|
skip(dummyUser, false, false)
|
2015-08-10 01:41:26 +02:00
|
|
|
}
|
|
|
|
|
2015-08-12 23:46:09 +02:00
|
|
|
os.Exit(0)
|
2015-08-15 16:57:55 +02:00
|
|
|
dummyClient.Disconnect()
|
2015-08-10 01:41:26 +02:00
|
|
|
}
|