Making Duration of type time.Duration

This commit is contained in:
MichaelOultram 2015-09-26 16:15:41 +01:00
parent cd03a947ed
commit 508065f608
3 changed files with 5 additions and 13 deletions

View file

@ -170,7 +170,6 @@ func isNil(a interface{}) bool {
}
// dj variable declaration. This is done outside of main() to allow global use.
var dj = mumbledj{
keepAlive: make(chan bool),
queue: NewSongQueue(),
playlistSkips: make(map[string][]string),

View file

@ -37,8 +37,7 @@ type Song interface {
Title() string
ID() string
Filename() string
DurationInt() int
DurationString() string
Duration() time.Duration
Thumbnail() string
Playlist() Playlist
DontSkip() bool
@ -92,8 +91,7 @@ func FindServiceAndAdd(user *gumble.User, url string) error {
oldLength := dj.queue.Len()
for _, song := range songArray {
// Check song is not too long
time, _ := time.ParseDuration(song.DurationInt())
if dj.conf.General.MaxSongDuration == 0 || int(time.Seconds()) <= dj.conf.General.MaxSongDuration {
if dj.conf.General.MaxSongDuration == 0 || song.Duration().Seconds()) <= dj.conf.General.MaxSongDuration {
if !isNil(song.Playlist()) {
title = song.Playlist().Title()
} else {

View file

@ -169,15 +169,10 @@ func (dl *YouTubeSong) Filename() string {
return dl.id + "." + dl.format
}
// DurationInt returns number of seconds for the Song.
func (dl *YouTubeSong) DurationInt() string {
return duration
}
// DurationString returns the pretty version of duration for the Song.
func (dl *YouTubeSong) DurationString() string {
// Duration returns duration for the Song.
func (dl *YouTubeSong) Duration() time.Duration {
timeDuration, _ := time.ParseDuration(strconv.Itoa(dl.duration) + "s")
return timeDuration.String()
return timeDuration
}
// Thumbnail returns the thumbnail URL for the Song.