func parseNameToTVName(name string) string { tvName := "" r := types.RegexpUtil{Regex: tvNameRegex1} matches := r.FindStringSubmatchMap(name) if n, ok := matches["name"]; ok { tvName = n } else { r = types.RegexpUtil{Regex: tvNameRegex2} matches = r.FindStringSubmatchMap(name) if n, ok = matches["name"]; ok { tvName = n } else { tvName = name } } // Clean any remaining parts tvName = tvNameRegex.ReplaceAllString(tvName, " ") // Remove date from front tvName = tvDateStartRegex.ReplaceAllString(tvName, "") // Remove periods, underscored, anything between parenthesis. tvName = tvNameCleanerRegex.ReplaceAllString(tvName, " ") // Collapse multiple spaces and remove leading and trailing spaces tvName = strings.Join(strings.Fields(tvName), " ") tvName = strings.Trim(tvName, " ") return tvName }
func parseSeasonEp(name string) *showSeasonEp { for _, r := range regularShowRegexes { reu := types.RegexpUtil{Regex: r} m := reu.FindStringSubmatchMap(name) if len(m) > 0 { sse := &showSeasonEp{} if s, ok := m["season"]; ok { sse.Season = strings.TrimLeft(s, "0") } if s, ok := m["episode"]; ok { sse.Episode = strings.TrimLeft(s, "0") } if s, ok := m["lastepisode"]; ok { sse.LastEpisode = s } return sse } } m := seasonEpRegex7.FindStringSubmatch(name) if m != nil { return &showSeasonEp{ Season: m[3] + m[4], Episode: m[5] + "/" + m[6], Airdate: m[2], } } //TODO: add the rest return nil }