Making Duration of type time.Duration
This commit is contained in:
parent
cd03a947ed
commit
508065f608
1
main.go
1
main.go
|
@ -170,7 +170,6 @@ func isNil(a interface{}) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// dj variable declaration. This is done outside of main() to allow global use.
|
// dj variable declaration. This is done outside of main() to allow global use.
|
||||||
var dj = mumbledj{
|
|
||||||
keepAlive: make(chan bool),
|
keepAlive: make(chan bool),
|
||||||
queue: NewSongQueue(),
|
queue: NewSongQueue(),
|
||||||
playlistSkips: make(map[string][]string),
|
playlistSkips: make(map[string][]string),
|
||||||
|
|
|
@ -37,8 +37,7 @@ type Song interface {
|
||||||
Title() string
|
Title() string
|
||||||
ID() string
|
ID() string
|
||||||
Filename() string
|
Filename() string
|
||||||
DurationInt() int
|
Duration() time.Duration
|
||||||
DurationString() string
|
|
||||||
Thumbnail() string
|
Thumbnail() string
|
||||||
Playlist() Playlist
|
Playlist() Playlist
|
||||||
DontSkip() bool
|
DontSkip() bool
|
||||||
|
@ -92,8 +91,7 @@ func FindServiceAndAdd(user *gumble.User, url string) error {
|
||||||
oldLength := dj.queue.Len()
|
oldLength := dj.queue.Len()
|
||||||
for _, song := range songArray {
|
for _, song := range songArray {
|
||||||
// Check song is not too long
|
// Check song is not too long
|
||||||
time, _ := time.ParseDuration(song.DurationInt())
|
if dj.conf.General.MaxSongDuration == 0 || song.Duration().Seconds()) <= dj.conf.General.MaxSongDuration {
|
||||||
if dj.conf.General.MaxSongDuration == 0 || int(time.Seconds()) <= dj.conf.General.MaxSongDuration {
|
|
||||||
if !isNil(song.Playlist()) {
|
if !isNil(song.Playlist()) {
|
||||||
title = song.Playlist().Title()
|
title = song.Playlist().Title()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -169,15 +169,10 @@ func (dl *YouTubeSong) Filename() string {
|
||||||
return dl.id + "." + dl.format
|
return dl.id + "." + dl.format
|
||||||
}
|
}
|
||||||
|
|
||||||
// DurationInt returns number of seconds for the Song.
|
// Duration returns duration for the Song.
|
||||||
func (dl *YouTubeSong) DurationInt() string {
|
func (dl *YouTubeSong) Duration() time.Duration {
|
||||||
return duration
|
|
||||||
}
|
|
||||||
|
|
||||||
// DurationString returns the pretty version of duration for the Song.
|
|
||||||
func (dl *YouTubeSong) DurationString() string {
|
|
||||||
timeDuration, _ := time.ParseDuration(strconv.Itoa(dl.duration) + "s")
|
timeDuration, _ := time.ParseDuration(strconv.Itoa(dl.duration) + "s")
|
||||||
return timeDuration.String()
|
return timeDuration
|
||||||
}
|
}
|
||||||
|
|
||||||
// Thumbnail returns the thumbnail URL for the Song.
|
// Thumbnail returns the thumbnail URL for the Song.
|
||||||
|
|
Reference in a new issue