From 0721ecee63dade7358c048a2f415f638ed35a382 Mon Sep 17 00:00:00 2001 From: bytedream Date: Wed, 1 Dec 2021 17:19:19 +0100 Subject: [PATCH] Updated url regex: minus sign in normal url; locale in beta url --- crunchyroll.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crunchyroll.go b/crunchyroll.go index 189ad80..e47182a 100644 --- a/crunchyroll.go +++ b/crunchyroll.go @@ -357,7 +357,7 @@ func MatchEpisode(url string) (seriesName, title string, ok bool) { // Note that the episode number can be misleading. For example if an episode has the episode number 23.5 (slime isekai) // the episode number will be 235 func ParseEpisodeURL(url string) (seriesName, title string, episodeNumber int, webId int, ok bool) { - pattern := regexp.MustCompile(`(?m)^https?://(www\.)?crunchyroll\.com(/\w{2}(-\w{2})?)?/(?P[^/]+)/episode-(?P\d+)-(?P\w+)-(?P<webId>\d+).*`) + pattern := regexp.MustCompile(`(?m)^https?://(www\.)?crunchyroll\.com(/\w{2}(-\w{2})?)?/(?P<series>[^/]+)/episode-(?P<number>\d+)-(?P<title>.+)-(?P<webId>\d+).*`) if urlMatch := pattern.FindAllStringSubmatch(url, -1); len(urlMatch) != 0 { groups := regexGroups(urlMatch, pattern.SubexpNames()...) seriesName = groups["series"] @@ -374,7 +374,7 @@ func ParseEpisodeURL(url string) (seriesName, title string, episodeNumber int, w // ParseBetaSeriesURL tries to extract the season id of the given crunchyroll beta url, pointing to a season func ParseBetaSeriesURL(url string) (seasonId string, ok bool) { - pattern := regexp.MustCompile(`(?m)^https?://(www\.)?beta\.crunchyroll\.com/series/(?P<seasonId>\w+).*`) + pattern := regexp.MustCompile(`(?m)^https?://(www\.)?beta\.crunchyroll\.com/(\w{2}/)?series/(?P<seasonId>\w+).*`) if urlMatch := pattern.FindAllStringSubmatch(url, -1); len(urlMatch) != 0 { groups := regexGroups(urlMatch, pattern.SubexpNames()...) seasonId = groups["seasonId"] @@ -385,7 +385,7 @@ func ParseBetaSeriesURL(url string) (seasonId string, ok bool) { // ParseBetaEpisodeURL tries to extract the episode id of the given crunchyroll beta url, pointing to an episode func ParseBetaEpisodeURL(url string) (episodeId string, ok bool) { - pattern := regexp.MustCompile(`(?m)^https?://(www\.)?beta\.crunchyroll\.com/watch/(?P<episodeId>\w+).*`) + pattern := regexp.MustCompile(`(?m)^https?://(www\.)?beta\.crunchyroll\.com/(\w{2}/)?watch/(?P<episodeId>\w+).*`) if urlMatch := pattern.FindAllStringSubmatch(url, -1); len(urlMatch) != 0 { groups := regexGroups(urlMatch, pattern.SubexpNames()...) episodeId = groups["episodeId"]