]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/ondemandkorea.py
Rename bypass geo restriction options
[yt-dlp.git] / youtube_dl / extractor / ondemandkorea.py
CommitLineData
594601f5 1# coding: utf-8
2from __future__ import unicode_literals
3
a4a554a7 4from .common import InfoExtractor
47c914f9
S
5from ..utils import (
6 ExtractorError,
7 js_to_json,
8)
594601f5 9
594601f5 10
a4a554a7 11class OnDemandKoreaIE(InfoExtractor):
594601f5 12 _VALID_URL = r'https?://(?:www\.)?ondemandkorea\.com/(?P<id>[^/]+)\.html'
13 _TEST = {
14 'url': 'http://www.ondemandkorea.com/ask-us-anything-e43.html',
15 'info_dict': {
16 'id': 'ask-us-anything-e43',
17 'ext': 'mp4',
18 'title': 'Ask Us Anything : E43',
ec85ded8 19 'thumbnail': r're:^https?://.*\.jpg$',
594601f5 20 },
21 'params': {
22 'skip_download': 'm3u8 download'
23 }
24 }
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 webpage = self._download_webpage(url, video_id, fatal=False)
29
30 if not webpage:
31 # Page sometimes returns captcha page with HTTP 403
47c914f9
S
32 raise ExtractorError(
33 'Unable to access page. You may have been blocked.',
34 expected=True)
594601f5 35
36 if 'msg_block_01.png' in webpage:
47c914f9 37 self.raise_geo_restricted(
01b1aa9f
S
38 msg='This content is not available in your region',
39 countries=['US', 'CA'])
47c914f9 40
594601f5 41 if 'This video is only available to ODK PLUS members.' in webpage:
47c914f9
S
42 raise ExtractorError(
43 'This video is only available to ODK PLUS members.',
44 expected=True)
594601f5 45
46 title = self._og_search_title(webpage)
594601f5 47
47c914f9
S
48 jw_config = self._parse_json(
49 self._search_regex(
50 r'(?s)jwplayer\(([\'"])(?:(?!\1).)+\1\)\.setup\s*\((?P<options>.+?)\);',
51 webpage, 'jw config', group='options'),
52 video_id, transform_source=js_to_json)
53 info = self._parse_jwplayer_data(
54 jw_config, video_id, require_title=False, m3u8_id='hls',
55 base_url=url)
594601f5 56
47c914f9 57 info.update({
594601f5 58 'title': title,
47c914f9
S
59 'thumbnail': self._og_search_thumbnail(webpage),
60 })
61 return info