From 08202a62a7251f2a471660bc83a1c2c8340ce52b Mon Sep 17 00:00:00 2001 From: df Date: Mon, 9 Aug 2021 16:24:12 +0100 Subject: [PATCH] Fix tests --- youtube_dl/extractor/comedycentral.py | 10 ++++++++-- youtube_dl/extractor/generic.py | 3 +++ youtube_dl/extractor/mtv.py | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/comedycentral.py b/youtube_dl/extractor/comedycentral.py index bad0f737c..b2d26f523 100644 --- a/youtube_dl/extractor/comedycentral.py +++ b/youtube_dl/extractor/comedycentral.py @@ -16,7 +16,7 @@ class ComedyCentralIE(MTVServicesInfoExtractor): _TESTS = [{ 'url': 'http://www.cc.com/video-clips/5ke9v2/the-daily-show-with-trevor-noah-doc-rivers-and-steve-ballmer---the-nba-player-strike', - 'md5': 'b8acb347177c680ff18a292aa2166f80', + 'md5': '58e7caf5c7c0c865d9d79f7d151e5090', 'info_dict': { 'id': '89ccc86e-1b02-4f83-b0c9-1d9592ecd025', 'ext': 'mp4', @@ -25,6 +25,9 @@ class ComedyCentralIE(MTVServicesInfoExtractor): 'timestamp': 1598670000, 'upload_date': '20200829', }, + 'params': { + 'hls_prefer_native': False, + }, }, { 'url': 'http://www.cc.com/episodes/pnzzci/drawn-together--american-idol--parody-clip-show-season-3-ep-314', 'only_matching': True, @@ -37,10 +40,13 @@ class ComedyCentralIE(MTVServicesInfoExtractor): 'id': '2f56e756-91ec-4d68-8799-e3b710e360e4', 'ext': 'mp4', 'title': 'The Daily Show with Trevor Noah|August 4, 2021|26|NO-EPISODE#|Hottest Take - The Olympics', - 'description': 'md5:f877effd54484878f0aaddbe418314f4', + 'description': 'md5:104484314a4cba36d8c62b094523efc8', 'timestamp': 1628125200, 'upload_date': '20210805', }, + 'params': { + 'hls_prefer_native': False, + }, }, ] diff --git a/youtube_dl/extractor/generic.py b/youtube_dl/extractor/generic.py index a9c064105..d4b4883e6 100644 --- a/youtube_dl/extractor/generic.py +++ b/youtube_dl/extractor/generic.py @@ -901,6 +901,9 @@ class GenericIE(InfoExtractor): 'timestamp': 1349922600, 'upload_date': '20121011', }, + 'params': { + 'hls-prefer-native': False, + }, }, # YouTube embed via { diff --git a/youtube_dl/extractor/mtv.py b/youtube_dl/extractor/mtv.py index 965145b38..5008d33ae 100644 --- a/youtube_dl/extractor/mtv.py +++ b/youtube_dl/extractor/mtv.py @@ -292,7 +292,7 @@ class MTVServicesInfoExtractor(InfoExtractor): main_container = self._extract_child_with_type(data, 'MainContainer') ab_testing = self._extract_child_with_type(main_container, 'ABTesting') video_player = self._extract_child_with_type(ab_testing or main_container, 'VideoPlayer') - mgid = video_player['props']['media']['video']['config']['uri'] + mgid = try_get(video_player, lambda x: x['props']['media']['video']['config']['uri']) return mgid @@ -300,6 +300,8 @@ class MTVServicesInfoExtractor(InfoExtractor): title = url_basename(url) webpage = self._download_webpage(url, title) mgid = self._extract_mgid(webpage) + if not mgid: + raise ExtractorError('Unable to determine MTVServices ID (mgid)', expected=True) videos_info = self._get_videos_info(mgid) if videos_info and videos_info.get('_type') != 'playlist': videos_info['display_id'] = title