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.
|
||||
var dj = mumbledj{
|
||||
keepAlive: make(chan bool),
|
||||
queue: NewSongQueue(),
|
||||
playlistSkips: make(map[string][]string),
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
Reference in a new issue