From c25d6881e88bc0d92d2a6aa7d6f167a247365130 Mon Sep 17 00:00:00 2001 From: Michael Tilbury Date: Sun, 14 Apr 2019 18:30:46 -0400 Subject: [PATCH 1/4] [BYUtv] Add support for akamai VODs (addresses #20574) Fix code style on brackets (flake8) Add more information to test info_dict --- youtube_dl/extractor/byutv.py | 63 +++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/youtube_dl/extractor/byutv.py b/youtube_dl/extractor/byutv.py index 4bf4efe1f..e2867c664 100644 --- a/youtube_dl/extractor/byutv.py +++ b/youtube_dl/extractor/byutv.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import re from .common import InfoExtractor +from ..utils import url_basename class BYUtvIE(InfoExtractor): @@ -22,6 +23,27 @@ class BYUtvIE(InfoExtractor): 'skip_download': True, }, 'add_ie': ['Ooyala'], + }, { + 'url': 'https://www.byutv.org/player/a5467e14-c7f2-46f9-b3c2-cb31a56749c6/byu-soccer-w-argentina-vs-byu-4419', + 'info_dict': { + 'id': 'a5467e14-c7f2-46f9-b3c2-cb31a56749c6', + 'display_id': 'byu-soccer-w-argentina-vs-byu-4419', + 'ext': 'mp4', + 'title': 'Argentina vs. BYU (4/4/19)', + 'length': '02:05:43', + }, + }, { + 'url': 'https://www.byutv.org/player/a5467e14-c7f2-46f9-b3c2-cb31a56749c6/byu-soccer-w-argentina-vs-byu-4419', + 'info_dict': { + 'id': 'a5467e14-c7f2-46f9-b3c2-cb31a56749c6', + 'display_id': 'byu-soccer-w-argentina-vs-byu-4419', + 'ext': 'mp4', + 'title': 'Argentina vs. BYU (4/4/19)', + 'length': '02:05:43', + }, + 'params': { + 'skip_download': True + }, }, { 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d', 'only_matching': True, @@ -33,9 +55,8 @@ class BYUtvIE(InfoExtractor): def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') - display_id = mobj.group('display_id') or video_id - ep = self._download_json( + info = self._download_json( 'https://api.byutv.org/api3/catalog/getvideosforcontent', video_id, query={ 'contentid': video_id, @@ -44,15 +65,31 @@ class BYUtvIE(InfoExtractor): }, headers={ 'x-byutv-context': 'web$US', 'x-byutv-platformkey': 'xsaaw9c7y5', - })['ooyalaVOD'] + }) - return { - '_type': 'url_transparent', - 'ie_key': 'Ooyala', - 'url': 'ooyala:%s' % ep['providerId'], - 'id': video_id, - 'display_id': display_id, - 'title': ep.get('title'), - 'description': ep.get('description'), - 'thumbnail': ep.get('imageThumbnail'), - } + if 'ooyalaVOD' in info: + ep = info['ooyalaVOD'] + return { + '_type': 'url_transparent', + 'ie_key': 'Ooyala', + 'url': 'ooyala:%s' % ep['providerId'], + 'id': video_id, + 'display_id': mobj.group('display_id') or video_id, + 'title': ep.get('title'), + 'description': ep.get('description'), + 'thumbnail': ep.get('imageThumbnail'), + } + elif 'dvr' in info: + ep = info['dvr'] + formats = self._extract_m3u8_formats( + ep['videoUrl'], video_id, 'mp4', entry_protocol='m3u8_native' + ) + return { + 'formats': formats, + 'id': video_id, + 'display_id': url_basename(url), + 'title': ep.get('title'), + 'description': ep.get('description'), + 'thumbnail': ep.get('imageThumbnail'), + 'length': ep.get('length'), + } From 3948517e2172ccabe05ad478d16bc1c4083dbe77 Mon Sep 17 00:00:00 2001 From: Michael Tilbury Date: Sun, 14 Apr 2019 19:42:11 -0400 Subject: [PATCH 2/4] Apply fixes Remove duplicate test Change 'in' check to use get() Raise ExtractorError instead of returning None Made 'title' field mandatory Removed 'length' field in info_dict --- youtube_dl/extractor/byutv.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/youtube_dl/extractor/byutv.py b/youtube_dl/extractor/byutv.py index e2867c664..b69b9eec4 100644 --- a/youtube_dl/extractor/byutv.py +++ b/youtube_dl/extractor/byutv.py @@ -3,7 +3,10 @@ from __future__ import unicode_literals import re from .common import InfoExtractor -from ..utils import url_basename +from ..utils import ( + ExtractorError, + url_basename, +) class BYUtvIE(InfoExtractor): @@ -30,16 +33,6 @@ class BYUtvIE(InfoExtractor): 'display_id': 'byu-soccer-w-argentina-vs-byu-4419', 'ext': 'mp4', 'title': 'Argentina vs. BYU (4/4/19)', - 'length': '02:05:43', - }, - }, { - 'url': 'https://www.byutv.org/player/a5467e14-c7f2-46f9-b3c2-cb31a56749c6/byu-soccer-w-argentina-vs-byu-4419', - 'info_dict': { - 'id': 'a5467e14-c7f2-46f9-b3c2-cb31a56749c6', - 'display_id': 'byu-soccer-w-argentina-vs-byu-4419', - 'ext': 'mp4', - 'title': 'Argentina vs. BYU (4/4/19)', - 'length': '02:05:43', }, 'params': { 'skip_download': True @@ -67,7 +60,7 @@ class BYUtvIE(InfoExtractor): 'x-byutv-platformkey': 'xsaaw9c7y5', }) - if 'ooyalaVOD' in info: + if info.get('ooyalaVOD'): ep = info['ooyalaVOD'] return { '_type': 'url_transparent', @@ -75,11 +68,11 @@ class BYUtvIE(InfoExtractor): 'url': 'ooyala:%s' % ep['providerId'], 'id': video_id, 'display_id': mobj.group('display_id') or video_id, - 'title': ep.get('title'), + 'title': ep['title'], 'description': ep.get('description'), 'thumbnail': ep.get('imageThumbnail'), } - elif 'dvr' in info: + elif info.get('dvr'): ep = info['dvr'] formats = self._extract_m3u8_formats( ep['videoUrl'], video_id, 'mp4', entry_protocol='m3u8_native' @@ -88,8 +81,9 @@ class BYUtvIE(InfoExtractor): 'formats': formats, 'id': video_id, 'display_id': url_basename(url), - 'title': ep.get('title'), + 'title': ep['title'], 'description': ep.get('description'), 'thumbnail': ep.get('imageThumbnail'), - 'length': ep.get('length'), } + else: + raise ExtractorError('Unrecognized VOD type.') From ff92503189c00262f9ca737194208cf7dcd5c2d9 Mon Sep 17 00:00:00 2001 From: Michael Tilbury Date: Mon, 15 Apr 2019 13:38:49 -0400 Subject: [PATCH 3/4] Apply fixes: Make title field optional for ooyala extraction (the ooyala IE can get the title) Remove duplication of get() call Sort m3u8 formats Made 'dvr' mandatory if not ooyalaVOD Extract duration for akamai videos --- youtube_dl/extractor/byutv.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/youtube_dl/extractor/byutv.py b/youtube_dl/extractor/byutv.py index b69b9eec4..4ce2eb91f 100644 --- a/youtube_dl/extractor/byutv.py +++ b/youtube_dl/extractor/byutv.py @@ -6,6 +6,7 @@ from .common import InfoExtractor from ..utils import ( ExtractorError, url_basename, + parse_duration, ) @@ -33,6 +34,7 @@ class BYUtvIE(InfoExtractor): 'display_id': 'byu-soccer-w-argentina-vs-byu-4419', 'ext': 'mp4', 'title': 'Argentina vs. BYU (4/4/19)', + 'duration': 7543.0, }, 'params': { 'skip_download': True @@ -60,23 +62,25 @@ class BYUtvIE(InfoExtractor): 'x-byutv-platformkey': 'xsaaw9c7y5', }) - if info.get('ooyalaVOD'): - ep = info['ooyalaVOD'] + ep = info.get('ooyalaVOD') + if ep: return { '_type': 'url_transparent', 'ie_key': 'Ooyala', 'url': 'ooyala:%s' % ep['providerId'], 'id': video_id, 'display_id': mobj.group('display_id') or video_id, - 'title': ep['title'], + 'title': ep.get('title'), 'description': ep.get('description'), 'thumbnail': ep.get('imageThumbnail'), } - elif info.get('dvr'): + else: + info = {} ep = info['dvr'] formats = self._extract_m3u8_formats( ep['videoUrl'], video_id, 'mp4', entry_protocol='m3u8_native' ) + self._sort_formats(formats) return { 'formats': formats, 'id': video_id, @@ -84,6 +88,5 @@ class BYUtvIE(InfoExtractor): 'title': ep['title'], 'description': ep.get('description'), 'thumbnail': ep.get('imageThumbnail'), + 'duration': parse_duration(ep.get('length')) } - else: - raise ExtractorError('Unrecognized VOD type.') From 970a1557309517cd3826912157b8197131b94b47 Mon Sep 17 00:00:00 2001 From: Michael Tilbury Date: Mon, 15 Apr 2019 13:46:07 -0400 Subject: [PATCH 4/4] Remove unused ExtractorError import --- youtube_dl/extractor/byutv.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/youtube_dl/extractor/byutv.py b/youtube_dl/extractor/byutv.py index 4ce2eb91f..1ec56f42a 100644 --- a/youtube_dl/extractor/byutv.py +++ b/youtube_dl/extractor/byutv.py @@ -4,7 +4,6 @@ import re from .common import InfoExtractor from ..utils import ( - ExtractorError, url_basename, parse_duration, ) @@ -75,7 +74,6 @@ class BYUtvIE(InfoExtractor): 'thumbnail': ep.get('imageThumbnail'), } else: - info = {} ep = info['dvr'] formats = self._extract_m3u8_formats( ep['videoUrl'], video_id, 'mp4', entry_protocol='m3u8_native' @@ -88,5 +86,5 @@ class BYUtvIE(InfoExtractor): 'title': ep['title'], 'description': ep.get('description'), 'thumbnail': ep.get('imageThumbnail'), - 'duration': parse_duration(ep.get('length')) + 'duration': parse_duration(ep.get('length')), }