From f01cb57630ef5511829e8c8353e6382b7ec389ca Mon Sep 17 00:00:00 2001 From: Ruowang Sun Date: Sun, 11 Dec 2022 20:35:11 -0500 Subject: [PATCH] [Callin] Add new extractor --- youtube_dl/extractor/callin.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/youtube_dl/extractor/callin.py b/youtube_dl/extractor/callin.py index 4840bb71d..372bf19fe 100644 --- a/youtube_dl/extractor/callin.py +++ b/youtube_dl/extractor/callin.py @@ -5,8 +5,10 @@ from .common import InfoExtractor from ..utils import ( ExtractorError, traverse_obj, + try_get, ) + class CallinIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?callin\.com/episode/(?:[^/#?-]+-)*(?P[^/#?-]+)' _TESTS = [{ @@ -39,31 +41,29 @@ class CallinIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) - # webpage_json = self._download_json(url, video_id) next_data = self._search_nextjs_data(webpage, video_id) valid = traverse_obj(next_data, ('props', 'pageProps', 'episode')) if not valid: raise ExtractorError('Failed to find m3u8') - - episode = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['episode'] + + episode = try_get(next_data, lambda x: x['props']['pageProps']['episode'], dict) title = episode.get('title') if not title: title = self._og_search_title(webpage) description = episode.get('description') if not description: description = self._og_search_description(webpage) - + formats = [] m3u8_url = episode.get('m3u8') if m3u8_url: formats.extend(self._extract_m3u8_formats( m3u8_url, video_id, 'mp4', fatal=False)) - # self._sort_formats(formats) return { 'id': video_id, 'title': title, 'description': description, 'formats': formats, - } \ No newline at end of file + }