2016-09-27 15:29:21 +10:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2017-02-17 02:42:36 +11:00
|
|
|
from .common import InfoExtractor
|
2016-12-17 22:47:49 +11:00
|
|
|
from ..utils import (
|
|
|
|
ExtractorError,
|
|
|
|
js_to_json,
|
|
|
|
)
|
2016-09-27 15:29:21 +10:00
|
|
|
|
|
|
|
|
2017-02-17 02:42:36 +11:00
|
|
|
class OnDemandKoreaIE(InfoExtractor):
|
2016-09-27 15:29:21 +10:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?ondemandkorea\.com/(?P<id>[^/]+)\.html'
|
|
|
|
_TEST = {
|
|
|
|
'url': 'http://www.ondemandkorea.com/ask-us-anything-e43.html',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'ask-us-anything-e43',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Ask Us Anything : E43',
|
2017-01-02 23:08:07 +11:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2016-09-27 15:29:21 +10:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': 'm3u8 download'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
webpage = self._download_webpage(url, video_id, fatal=False)
|
|
|
|
|
|
|
|
if not webpage:
|
|
|
|
# Page sometimes returns captcha page with HTTP 403
|
2016-12-17 22:47:49 +11:00
|
|
|
raise ExtractorError(
|
|
|
|
'Unable to access page. You may have been blocked.',
|
|
|
|
expected=True)
|
2016-09-27 15:29:21 +10:00
|
|
|
|
|
|
|
if 'msg_block_01.png' in webpage:
|
2016-12-17 22:47:49 +11:00
|
|
|
self.raise_geo_restricted(
|
2017-02-04 22:52:11 +11:00
|
|
|
msg='This content is not available in your region',
|
|
|
|
countries=['US', 'CA'])
|
2016-12-17 22:47:49 +11:00
|
|
|
|
2016-09-27 15:29:21 +10:00
|
|
|
if 'This video is only available to ODK PLUS members.' in webpage:
|
2016-12-17 22:47:49 +11:00
|
|
|
raise ExtractorError(
|
|
|
|
'This video is only available to ODK PLUS members.',
|
|
|
|
expected=True)
|
2016-09-27 15:29:21 +10:00
|
|
|
|
|
|
|
title = self._og_search_title(webpage)
|
|
|
|
|
2016-12-17 22:47:49 +11:00
|
|
|
jw_config = self._parse_json(
|
|
|
|
self._search_regex(
|
|
|
|
r'(?s)jwplayer\(([\'"])(?:(?!\1).)+\1\)\.setup\s*\((?P<options>.+?)\);',
|
|
|
|
webpage, 'jw config', group='options'),
|
|
|
|
video_id, transform_source=js_to_json)
|
|
|
|
info = self._parse_jwplayer_data(
|
|
|
|
jw_config, video_id, require_title=False, m3u8_id='hls',
|
|
|
|
base_url=url)
|
2016-09-27 15:29:21 +10:00
|
|
|
|
2016-12-17 22:47:49 +11:00
|
|
|
info.update({
|
2016-09-27 15:29:21 +10:00
|
|
|
'title': title,
|
2016-12-17 22:47:49 +11:00
|
|
|
'thumbnail': self._og_search_thumbnail(webpage),
|
|
|
|
})
|
|
|
|
return info
|