mirror of https://github.com/fluffle/goirc
Handle YouTube responses without durations (blocked videos)
This commit is contained in:
parent
2debf26308
commit
0c7aba3fc3
28
handler.go
28
handler.go
|
@ -114,26 +114,26 @@ func youtube(conn *irc.Conn, nick, video, channel string) {
|
||||||
var yte = entry{"", group{duration{""}}}
|
var yte = entry{"", group{duration{""}}}
|
||||||
|
|
||||||
err = xml.Unmarshal(response.Body, &yte)
|
err = xml.Unmarshal(response.Body, &yte)
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
seconds, err := strconv.Atoui(yte.Group.Duration.Seconds)
|
seconds, err := strconv.Atoui(yte.Group.Duration.Seconds)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
return
|
minutes := seconds / 60
|
||||||
}
|
seconds = seconds % 60
|
||||||
minutes := seconds / 60
|
hours := minutes / 60
|
||||||
seconds = seconds % 60
|
minutes = minutes % 60
|
||||||
hours := minutes / 60
|
var durationStr string
|
||||||
minutes = minutes % 60
|
if hours > 0 {
|
||||||
var durationStr string
|
durationStr = fmt.Sprintf("%d:%02d:%02d", hours, minutes, seconds)
|
||||||
if hours > 0 {
|
} else {
|
||||||
durationStr = fmt.Sprintf("%d:%02d:%02d", hours, minutes, seconds)
|
durationStr = fmt.Sprintf("%02d:%02d", minutes, seconds)
|
||||||
|
}
|
||||||
|
say(conn, channel, "%s's video: %s, %s", nick, yte.Title, durationStr)
|
||||||
} else {
|
} else {
|
||||||
durationStr = fmt.Sprintf("%02d:%02d", minutes, seconds)
|
say(conn, channel, "%s's video: %s", nick, yte.Title)
|
||||||
}
|
}
|
||||||
|
|
||||||
say(conn, channel, "%s's video: %s, %s", nick, yte.Title, durationStr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func translate(conn *irc.Conn, nick, args, target string) {
|
func translate(conn *irc.Conn, nick, args, target string) {
|
||||||
|
|
Loading…
Reference in New Issue