[ie/crunchyroll:show] Implement language filter extractor arg

This commit is contained in:
Simon Sawicki 2023-09-24 23:19:18 +02:00
parent 8b46ad4d8b
commit 2e962821ae
No known key found for this signature in database
2 changed files with 10 additions and 0 deletions

View file

@ -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`

View file

@ -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})):