This commit is contained in:
Matthieu Grieger 2015-05-19 01:21:33 -07:00
parent 1615ed38e9
commit 2173edd1c6

View file

@ -59,8 +59,10 @@ func NewYouTubeSong(user, id, offset string, playlist *YouTubePlaylist) (*YouTub
offsetMatch := offsetExp.FindStringSubmatch(offset)
offsetResult := make(map[string]string)
for i, name := range offsetExp.SubexpNames() {
if i < len(offsetMatch) {
offsetResult[name] = offsetMatch[i]
}
}
if offsetResult["days"] != "" {
offsetDays, _ = strconv.ParseInt(strings.TrimSuffix(offsetResult["days"], "d"), 10, 32)
@ -85,8 +87,10 @@ func NewYouTubeSong(user, id, offset string, playlist *YouTubePlaylist) (*YouTub
timestampMatch := timestampExp.FindStringSubmatch(duration)
timestampResult := make(map[string]string)
for i, name := range timestampExp.SubexpNames() {
if i < len(timestampMatch) {
timestampResult[name] = timestampMatch[i]
}
}
if timestampResult["days"] != "" {
days, _ = strconv.ParseInt(strings.TrimSuffix(timestampResult["days"], "D"), 10, 32)
@ -354,9 +358,12 @@ func NewYouTubePlaylist(user, id string) (*YouTubePlaylist, error) {
timestampExp := regexp.MustCompile(`P(?P<days>\d+D)?T(?P<hours>\d+H)?(?P<minutes>\d+M)?(?P<seconds>\d+S)?`)
timestampMatch := timestampExp.FindStringSubmatch(videoDuration)
timestampResult := make(map[string]string)
fmt.Println(timestampExp.SubexpNames())
for i, name := range timestampExp.SubexpNames() {
if i < len(timestampMatch) {
timestampResult[name] = timestampMatch[i]
}
}
if timestampResult["days"] != "" {
days, _ = strconv.ParseInt(strings.TrimSuffix(timestampResult["days"], "D"), 10, 32)