From 2e962821ae8c40e5e64f8a281b27192c0fdc320c Mon Sep 17 00:00:00 2001 From: Simon Sawicki Date: Sun, 24 Sep 2023 23:19:18 +0200 Subject: [PATCH] [ie/crunchyroll:show] Implement language filter extractor arg --- README.md | 3 +++ yt_dlp/extractor/crunchyroll.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index e8cd6d3a0..5b4666215 100644 --- a/README.md +++ b/README.md @@ -1791,6 +1791,9 @@ #### funimation #### crunchyrollbeta (Crunchyroll) * `hardsub`: One or more hardsub versions to extract (in order of preference), or `all` (default: `None` = no hardsubs will be extracted), e.g. `crunchyrollbeta:hardsub=en-US,de-DE` +#### crunchyrollbetashow (Crunchyroll) +* `language`: The language variants to extract, or `all` (default: `all`) + #### vikichannel * `video_types`: Types of videos to download - one or more of `episodes`, `movies`, `clips`, `trailers` diff --git a/yt_dlp/extractor/crunchyroll.py b/yt_dlp/extractor/crunchyroll.py index ea54f0195..c374c0ddc 100644 --- a/yt_dlp/extractor/crunchyroll.py +++ b/yt_dlp/extractor/crunchyroll.py @@ -514,10 +514,17 @@ class CrunchyrollBetaShowIE(CrunchyrollCmsBaseIE): def _real_extract(self, url): lang, internal_id = self._match_valid_url(url).group('lang', 'id') + requested_languages = set(self._configuration_arg('language')) + if 'all' in requested_languages: + requested_languages = set() def entries(): seasons_response = self._call_cms_api_signed(f'seasons?series_id={internal_id}', internal_id, lang, 'seasons') for season in traverse_obj(seasons_response, ('items', ..., {dict})): + if requested_languages: + season_languages = traverse_obj(season, ((('audio_locales', ...), 'audio_locale'), {str.lower})) + if season_languages and not requested_languages.intersection(season_languages): + continue episodes_response = self._call_cms_api_signed( f'episodes?season_id={season["id"]}', season["id"], lang, 'episode list') for episode_response in traverse_obj(episodes_response, ('items', ..., {dict})):