From 54c138bba27307b4a55977cd40d6f7e13df2079f Mon Sep 17 00:00:00 2001 From: ealgase Date: Fri, 14 Dec 2018 18:38:26 -0500 Subject: [PATCH 1/3] [olympicchannel] Add support for site --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/olympicchannel.py | 46 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 youtube_dl/extractor/olympicchannel.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 87c7d8b0c..4b9f337e0 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -797,6 +797,7 @@ from .nzz import NZZIE from .odatv import OdaTVIE from .odnoklassniki import OdnoklassnikiIE from .oktoberfesttv import OktoberfestTVIE +from .olympicchannel import OlympicChannelIE from .ondemandkorea import OnDemandKoreaIE from .onet import ( OnetIE, diff --git a/youtube_dl/extractor/olympicchannel.py b/youtube_dl/extractor/olympicchannel.py new file mode 100644 index 000000000..084a6b249 --- /dev/null +++ b/youtube_dl/extractor/olympicchannel.py @@ -0,0 +1,46 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + +import re + + +class OlympicChannelIE(InfoExtractor): + IE_NAME = 'olympicchannel' + _VALID_URL = r'https?://(?:www\.)?olympicchannel\.com/(?P..)/video/detail/(?P.+)/?' + _TEST = { + 'url': 'https://www.olympicchannel.com/en/video/detail/news-of-the-week-with-ash-tulloch-x9414/', + 'md5': 'aee7e665ad4bf45936e0f5d861e56ac5', + 'info_dict': { + '_type': 'video', + 'id': 'E18112220', + 'ext': 'm3u8', + 'title': 'News of the Week with Ash Tulloch', + 'thumbnail': 'https://img.olympicchannel.com/images/image/private/t_social_share_thumb/primary/fzcmi2e6kji6cnjjs1xz', + 'description': 'Exclusive interviews with Rika Kihira after her Grand Prix finals win, Yuzuru Hanyu's coach on the injured star, and Valerie Adams on Tokyo.', + # TODO more properties, either as: + # * A value + # * MD5 checksum; start the string with md5: + # * A regular expression; start the string with re: + # * Any Python type (for example int or float) + }, + } + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) # video id isn't included in URL, but is in the URL to the video + display_id = mobj.group('display_id') # display id is in URL, however + webpage = self._download_webpage(url, display_id) + m3u8_url = self._html_search_regex(r'', webpage, 'm3u8_url') # extract URL of video's m3u8 playlist + title = self._html_search_regex(r'', webpage, 'title') or self._html_search_regex(r'(.+?) \| Olympic Channel', webpage, 'title') # extract title + video_id = self._search_regex(r'St1-_(.+)_', m3u8_url, 'id') # extract unique video id from m3u8 + thumbnail_url = self._html_search_regex(r'', webpage, 'thumbnail') + return { + '_type': 'video', + 'display_id': display_id, + 'id': video_id, + 'title': title, + 'description': self._og_search_description(webpage), + 'formats': self._extract_m3u8_formats(m3u8_url, video_id), + 'thumbnail': thumbnail_url, + } From 65e9416c74ed8872041e1abcc5ab76a89679e7e6 Mon Sep 17 00:00:00 2001 From: ealgase Date: Fri, 14 Dec 2018 20:12:44 -0500 Subject: [PATCH 2/3] [olympicchannel] add support for episodes of a series, fix video ID extraction --- youtube_dl/extractor/olympicchannel.py | 62 +++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/youtube_dl/extractor/olympicchannel.py b/youtube_dl/extractor/olympicchannel.py index 084a6b249..64ffac2d9 100644 --- a/youtube_dl/extractor/olympicchannel.py +++ b/youtube_dl/extractor/olympicchannel.py @@ -8,17 +8,66 @@ import re class OlympicChannelIE(InfoExtractor): IE_NAME = 'olympicchannel' - _VALID_URL = r'https?://(?:www\.)?olympicchannel\.com/(?P..)/video/detail/(?P.+)/?' + _VALID_URL = r'https?://(?:www\.)?olympicchannel\.com/(?P..)/(original-series|video)/detail/(.+?/.+?/)?(.+?/)?(?P.+)/?' + _TESTS = [ + { + 'url': 'https://www.olympicchannel.com/en/video/detail/news-of-the-week-with-ash-tulloch-x9414/', + 'md5': 'aee7e665ad4bf45936e0f5d861e56ac5', + 'info_dict': { + '_type': 'video', + 'id': 'E18112220', + 'ext': 'm3u8', + 'title': 'News of the Week with Ash Tulloch', + 'thumbnail': 'https://img.olympicchannel.com/images/image/private/t_social_share_thumb/primary/fzcmi2e6kji6cnjjs1xz', + 'description': 'Exclusive interviews with Rika Kihira after her Grand Prix finals win, Yuzuru Hanyu's coach on the injured star, and Valerie Adams on Tokyo.', + } + }, + { + 'url': 'https://www.olympicchannel.com/en/original-series/detail/fashion-behind-the-games/fashion-behind-the-games-season-1/episodes/past-and-present-field-hockey/', + 'md5': '0da7ace7ee712e777e56cdc736edfcb5', + 'info_dict': { + '_type': 'video', + 'id': 'E17060701', + 'ext': 'm3u8', + 'title': 'Past and Present – Field hockey', + 'thumbnail': 'https://img.olympicchannel.com/images/image/private/t_social_share_thumb/primary/z61ca9vgb4h6t6r2se1f', + 'description': 'We reunite a pair of "Las Leonas" and travel back to the early days of field hockey.', + } + }, + ] + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) # video id isn't included in URL, but is in the URL to the video + display_id = mobj.group('display_id') # display id is in URL, however + webpage = self._download_webpage(url, display_id) + m3u8_url = self._html_search_regex(r'', webpage, 'm3u8_url') # extract URL of video's m3u8 playlist + title = self._html_search_regex(r'', webpage, 'title') or self._html_search_regex(r'(.+?) \| Olympic Channel', webpage, 'title') # extract title + video_id = self._search_regex(r'_(.........)_', m3u8_url, 'id') # extract unique video id from m3u8 + thumbnail_url = self._html_search_regex(r'', webpage, 'thumbnail') + return { + '_type': 'video', + 'display_id': display_id, + 'id': video_id, + 'title': title, + 'description': self._og_search_description(webpage), + 'formats': self._extract_m3u8_formats(m3u8_url, video_id), + 'thumbnail': thumbnail_url, + } + +''' +class OlympicChannelOriginalIE(InfoExtractor): + IE_NAME = 'olympicchannel:original' + _VALID_URL = r'https?://(?:www\.)?olympicchannel\.com/(?P..)/original-series/detail/(?P.+)/episodes/(?P.+)/?' _TEST = { 'url': 'https://www.olympicchannel.com/en/video/detail/news-of-the-week-with-ash-tulloch-x9414/', 'md5': 'aee7e665ad4bf45936e0f5d861e56ac5', 'info_dict': { '_type': 'video', - 'id': 'E18112220', + 'id': 'E17060701', 'ext': 'm3u8', - 'title': 'News of the Week with Ash Tulloch', - 'thumbnail': 'https://img.olympicchannel.com/images/image/private/t_social_share_thumb/primary/fzcmi2e6kji6cnjjs1xz', - 'description': 'Exclusive interviews with Rika Kihira after her Grand Prix finals win, Yuzuru Hanyu's coach on the injured star, and Valerie Adams on Tokyo.', + 'title': 'Past and Present – Field hockey', + 'thumbnail': 'https://img.olympicchannel.com/images/image/private/t_social_share_thumb/primary/z61ca9vgb4h6t6r2se1f', + 'description': 'We reunite a pair of "Las Leonas" and travel back to the early days of field hockey.', # TODO more properties, either as: # * A value # * MD5 checksum; start the string with md5: @@ -36,7 +85,7 @@ class OlympicChannelIE(InfoExtractor): video_id = self._search_regex(r'St1-_(.+)_', m3u8_url, 'id') # extract unique video id from m3u8 thumbnail_url = self._html_search_regex(r'', webpage, 'thumbnail') return { - '_type': 'video', + '_type': 'multi_video', 'display_id': display_id, 'id': video_id, 'title': title, @@ -44,3 +93,4 @@ class OlympicChannelIE(InfoExtractor): 'formats': self._extract_m3u8_formats(m3u8_url, video_id), 'thumbnail': thumbnail_url, } +''' From aa0ab66c59bc62cf50054f5eb7c1292159d27faa Mon Sep 17 00:00:00 2001 From: ealgase Date: Fri, 14 Dec 2018 20:28:18 -0500 Subject: [PATCH 3/3] [olympicchannel] save downloaded videos with file extension .mp4 (previously .m3u8) --- youtube_dl/extractor/olympicchannel.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/olympicchannel.py b/youtube_dl/extractor/olympicchannel.py index 64ffac2d9..32b0742cb 100644 --- a/youtube_dl/extractor/olympicchannel.py +++ b/youtube_dl/extractor/olympicchannel.py @@ -16,7 +16,7 @@ class OlympicChannelIE(InfoExtractor): 'info_dict': { '_type': 'video', 'id': 'E18112220', - 'ext': 'm3u8', + 'ext': 'mp4', 'title': 'News of the Week with Ash Tulloch', 'thumbnail': 'https://img.olympicchannel.com/images/image/private/t_social_share_thumb/primary/fzcmi2e6kji6cnjjs1xz', 'description': 'Exclusive interviews with Rika Kihira after her Grand Prix finals win, Yuzuru Hanyu's coach on the injured star, and Valerie Adams on Tokyo.', @@ -28,7 +28,7 @@ class OlympicChannelIE(InfoExtractor): 'info_dict': { '_type': 'video', 'id': 'E17060701', - 'ext': 'm3u8', + 'ext': 'mp4', 'title': 'Past and Present – Field hockey', 'thumbnail': 'https://img.olympicchannel.com/images/image/private/t_social_share_thumb/primary/z61ca9vgb4h6t6r2se1f', 'description': 'We reunite a pair of "Las Leonas" and travel back to the early days of field hockey.', @@ -50,7 +50,7 @@ class OlympicChannelIE(InfoExtractor): 'id': video_id, 'title': title, 'description': self._og_search_description(webpage), - 'formats': self._extract_m3u8_formats(m3u8_url, video_id), + 'formats': self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4'), 'thumbnail': thumbnail_url, }