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