From c3dca171d0130c23d89c15bcd5ec57af7a1b4ef2 Mon Sep 17 00:00:00 2001 From: Mariusz Skoneczko Date: Thu, 23 Apr 2020 20:07:33 +1000 Subject: [PATCH] [AnimeLab] Correctly extract mpd and m3u8 formats --- youtube_dl/extractor/animelab.py | 48 +++++++++++++++++++------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/youtube_dl/extractor/animelab.py b/youtube_dl/extractor/animelab.py index 16f8495c5..0bd599935 100644 --- a/youtube_dl/extractor/animelab.py +++ b/youtube_dl/extractor/animelab.py @@ -8,6 +8,7 @@ from ..utils import ( urlencode_postdata, int_or_none, str_or_none, + determine_ext, ) from ..compat import compat_HTTPError @@ -152,25 +153,6 @@ class AnimeLabIE(AnimeLabBaseIE): current_format = current_video_list.copy() - current_format['url'] = url - quality_data = video_instance.get('videoQuality') - if quality_data: - quality = quality_data.get('name') or quality_data.get('description') - else: - quality = None - - height = None - if quality: - height = int_or_none(self._search_regex(r'(\d+)p?$', quality, 'Video format height', default=None)) - if height is None and quality.startswith('SD'): - # sometimes we are only told it's SD quality - height = 480 - - if height is None: - self.report_warning('Could not get height of video') - else: - current_format['height'] = height - format_id_parts = [] format_id_parts.append(str_or_none(video_instance.get('id'))) @@ -184,6 +166,34 @@ class AnimeLabIE(AnimeLabBaseIE): format_id_parts.append(current_format['language']) format_id = '_'.join([x for x in format_id_parts if x is not None]) + + ext = determine_ext(url) + if ext == 'm3u8': + m3u8_formats = self._extract_m3u8_formats( + url, video_id, m3u8_id=format_id, fatal=False) + formats.extend(m3u8_formats) + continue + elif ext == 'mpd': + mpd_formats = self._extract_mpd_formats( + url, video_id, mpd_id=format_id, fatal=False) + formats.extend(mpd_formats) + continue + + current_format['url'] = url + quality_data = video_instance.get('videoQuality') + if quality_data: + quality = quality_data.get('name') or quality_data.get('description') + else: + quality = None + + height = None + if quality: + height = int_or_none(self._search_regex(r'(\d+)p?$', quality, 'Video format height', default=None)) + + if height is None: + self.report_warning('Could not get height of video') + else: + current_format['height'] = height current_format['format_id'] = format_id formats.append(current_format)