mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Updated url regex: minus sign in normal url; locale in beta url
This commit is contained in:
parent
3aea319b7c
commit
0721ecee63
1 changed files with 3 additions and 3 deletions
|
|
@ -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)
|
// 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
|
// the episode number will be 235
|
||||||
func ParseEpisodeURL(url string) (seriesName, title string, episodeNumber int, webId int, ok bool) {
|
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<series>[^/]+)/episode-(?P<number>\d+)-(?P<title>\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 {
|
if urlMatch := pattern.FindAllStringSubmatch(url, -1); len(urlMatch) != 0 {
|
||||||
groups := regexGroups(urlMatch, pattern.SubexpNames()...)
|
groups := regexGroups(urlMatch, pattern.SubexpNames()...)
|
||||||
seriesName = groups["series"]
|
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
|
// 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) {
|
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 {
|
if urlMatch := pattern.FindAllStringSubmatch(url, -1); len(urlMatch) != 0 {
|
||||||
groups := regexGroups(urlMatch, pattern.SubexpNames()...)
|
groups := regexGroups(urlMatch, pattern.SubexpNames()...)
|
||||||
seasonId = groups["seasonId"]
|
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
|
// 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) {
|
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 {
|
if urlMatch := pattern.FindAllStringSubmatch(url, -1); len(urlMatch) != 0 {
|
||||||
groups := regexGroups(urlMatch, pattern.SubexpNames()...)
|
groups := regexGroups(urlMatch, pattern.SubexpNames()...)
|
||||||
episodeId = groups["episodeId"]
|
episodeId = groups["episodeId"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue