From 5da42f2b9b29e69cff8a2ea22d3cf9c586e470d6 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Fri, 12 Aug 2022 13:08:32 +0530 Subject: [PATCH] [extractor/crunchyroll] Improve `_VALID_URL`s Closes #4633 --- yt_dlp/extractor/crunchyroll.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/yt_dlp/extractor/crunchyroll.py b/yt_dlp/extractor/crunchyroll.py index fccf054803..d4968c13b2 100644 --- a/yt_dlp/extractor/crunchyroll.py +++ b/yt_dlp/extractor/crunchyroll.py @@ -114,7 +114,14 @@ def _add_skip_wall(url): class CrunchyrollIE(CrunchyrollBaseIE, VRVBaseIE): IE_NAME = 'crunchyroll' - _VALID_URL = r'https?://(?:(?Pwww|m)\.)?(?Pcrunchyroll\.(?:com|fr)/(?:media(?:-|/\?id=)|(?!series/|watch/)(?:[^/]+/){1,2}[^/?&]*?)(?P[0-9]+))(?:[/?&]|$)' + _VALID_URL = r'''(?x) + https?://(?:(?Pwww|m)\.)?(?P + crunchyroll\.(?:com|fr)/(?: + media(?:-|/\?id=)| + (?!series/|watch/)(?:[^/]+/){1,2}[^/?&#]*? + )(?P[0-9]+) + )(?:[/?&#]|$)''' + _TESTS = [{ 'url': 'http://www.crunchyroll.com/wanna-be-the-strongest-in-the-world/episode-1-an-idol-wrestler-is-born-645513', 'info_dict': { @@ -758,7 +765,11 @@ def _redirect_from_beta(self, url, lang, internal_id, display_id, is_episode, ie class CrunchyrollBetaIE(CrunchyrollBetaBaseIE): IE_NAME = 'crunchyroll:beta' - _VALID_URL = r'https?://beta\.crunchyroll\.com/(?P(?:\w{2}(?:-\w{2})?/)?)watch/(?P\w+)/(?P[\w\-]*)/?(?:\?|$)' + _VALID_URL = r'''(?x) + https?://beta\.crunchyroll\.com/ + (?P(?:\w{2}(?:-\w{2})?/)?) + watch/(?P\w+) + (?:/(?P[\w-]+))?/?(?:[?#]|$)''' _TESTS = [{ 'url': 'https://beta.crunchyroll.com/watch/GY2P1Q98Y/to-the-future', 'info_dict': { @@ -780,7 +791,7 @@ class CrunchyrollBetaIE(CrunchyrollBetaBaseIE): }, 'params': {'skip_download': 'm3u8'}, }, { - 'url': 'https://beta.crunchyroll.com/watch/GY2P1Q98Y/', + 'url': 'https://beta.crunchyroll.com/watch/GY2P1Q98Y', 'only_matching': True, }, { 'url': 'https://beta.crunchyroll.com/pt-br/watch/G8WUN8VKP/the-ruler-of-conspiracy', @@ -867,7 +878,11 @@ def _real_extract(self, url): class CrunchyrollBetaShowIE(CrunchyrollBetaBaseIE): IE_NAME = 'crunchyroll:playlist:beta' - _VALID_URL = r'https?://beta\.crunchyroll\.com/(?P(?:\w{2}(?:-\w{2})?/)?)series/(?P\w+)/(?P[\w\-]*)/?(?:\?|$)' + _VALID_URL = r'''(?x) + https?://beta\.crunchyroll\.com/ + (?P(?:\w{2}(?:-\w{2})?/)?) + series/(?P\w+) + (?:/(?P[\w-]+))?/?(?:[?#]|$)''' _TESTS = [{ 'url': 'https://beta.crunchyroll.com/series/GY19NQ2QR/Girl-Friend-BETA', 'info_dict': { @@ -876,7 +891,7 @@ class CrunchyrollBetaShowIE(CrunchyrollBetaBaseIE): }, 'playlist_mincount': 10, }, { - 'url': 'https://beta.crunchyroll.com/it/series/GY19NQ2QR/Girl-Friend-BETA', + 'url': 'https://beta.crunchyroll.com/it/series/GY19NQ2QR', 'only_matching': True, }]