Made the maximum song duration optional
This commit is contained in:
parent
d11b6326cc
commit
d37995b136
|
@ -22,9 +22,9 @@ PlaylistSkipRatio = 0.5
|
||||||
# NOTE: If you do not want a comment by default, set the variable equal to an empty string ("").
|
# NOTE: If you do not want a comment by default, set the variable equal to an empty string ("").
|
||||||
DefaultComment = "Hello! I am a bot. Type !help for a list of commands."
|
DefaultComment = "Hello! I am a bot. Type !help for a list of commands."
|
||||||
|
|
||||||
# Maximum song duration in seconds
|
# Maximum song duration in seconds (0 = unristrcted)
|
||||||
# Default Value 600
|
# Default Value: 0
|
||||||
MaxSongDuration = 600
|
MaxSongDuration = 0
|
||||||
|
|
||||||
[Cache]
|
[Cache]
|
||||||
|
|
||||||
|
|
2
song.go
2
song.go
|
@ -60,7 +60,7 @@ func NewSong(user, id string, playlist *Playlist) (*Song, error) {
|
||||||
duration, _ := jq.Int("data", "duration")
|
duration, _ := jq.Int("data", "duration")
|
||||||
videoDuration := fmt.Sprintf("%d:%02d", duration/60, duration%60)
|
videoDuration := fmt.Sprintf("%d:%02d", duration/60, duration%60)
|
||||||
|
|
||||||
if duration > dj.conf.General.MaxSongDuration {
|
if duration > dj.conf.General.MaxSongDuration && dj.conf.General.MaxSongDuration > 0 {
|
||||||
return nil, errors.New("video exceeds the maximum allowed duration.")
|
return nil, errors.New("video exceeds the maximum allowed duration.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue