2015-04-09 03:44:22 +02:00
|
|
|
/*
|
|
|
|
* MumbleDJ
|
|
|
|
* By Matthieu Grieger
|
2015-04-14 08:40:39 +02:00
|
|
|
* service.go
|
2015-04-09 03:44:22 +02:00
|
|
|
* Copyright (c) 2014, 2015 Matthieu Grieger (MIT License)
|
|
|
|
*/
|
|
|
|
|
2015-04-14 08:40:39 +02:00
|
|
|
package main
|
2015-04-09 03:44:22 +02:00
|
|
|
|
2015-07-27 23:27:23 +02:00
|
|
|
import (
|
|
|
|
"github.com/layeh/gopus"
|
|
|
|
"github.com/layeh/gumble/gumble"
|
|
|
|
"github.com/layeh/gumble/gumble_ffmpeg"
|
|
|
|
"github.com/layeh/gumble/gumbleutil"
|
|
|
|
)
|
|
|
|
|
2015-07-27 23:13:40 +02:00
|
|
|
// Service interface. Each service should implement these functions
|
|
|
|
type Service interface {
|
|
|
|
ServiceName() string
|
|
|
|
URLRegex(string) bool // Can service deal with URL
|
|
|
|
NewRequest(*gumble.User, string) error // Create song/playlist and add to the queue
|
|
|
|
}
|
|
|
|
|
2015-04-09 22:20:40 +02:00
|
|
|
// Song interface. Each service will implement these
|
2015-04-09 03:44:22 +02:00
|
|
|
// functions in their Song types.
|
2015-04-09 03:47:39 +02:00
|
|
|
type Song interface {
|
2015-04-14 08:40:39 +02:00
|
|
|
Download() error
|
2015-04-09 03:47:39 +02:00
|
|
|
Play()
|
2015-04-14 08:40:39 +02:00
|
|
|
Delete() error
|
2015-04-16 08:32:32 +02:00
|
|
|
AddSkip(string) error
|
|
|
|
RemoveSkip(string) error
|
|
|
|
SkipReached(int) bool
|
2015-04-14 08:40:39 +02:00
|
|
|
Submitter() string
|
|
|
|
Title() string
|
|
|
|
ID() string
|
|
|
|
Filename() string
|
|
|
|
Duration() string
|
|
|
|
Thumbnail() string
|
2015-04-16 08:32:32 +02:00
|
|
|
Playlist() Playlist
|
2015-04-14 08:40:39 +02:00
|
|
|
DontSkip() bool
|
2015-04-16 08:32:32 +02:00
|
|
|
SetDontSkip(bool)
|
2015-04-09 03:47:39 +02:00
|
|
|
}
|
2015-04-09 03:44:22 +02:00
|
|
|
|
2015-04-09 22:20:40 +02:00
|
|
|
// Playlist interface. Each service will implement these
|
2015-04-09 03:44:22 +02:00
|
|
|
// functions in their Playlist types.
|
2015-04-09 03:47:39 +02:00
|
|
|
type Playlist interface {
|
2015-04-16 08:32:32 +02:00
|
|
|
AddSkip(string) error
|
|
|
|
RemoveSkip(string) error
|
2015-04-09 03:47:39 +02:00
|
|
|
DeleteSkippers()
|
2015-04-16 08:32:32 +02:00
|
|
|
SkipReached(int) bool
|
2015-04-14 08:40:39 +02:00
|
|
|
ID() string
|
|
|
|
Title() string
|
2015-04-09 03:47:39 +02:00
|
|
|
}
|
2015-07-27 23:13:40 +02:00
|
|
|
|
|
|
|
var services = []Service{
|
2015-07-27 23:24:35 +02:00
|
|
|
new(YoutubeService),
|
2015-07-27 23:13:40 +02:00
|
|
|
}
|