]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/ondemandkorea.py
[youtube] Improve signature function detection (#641)
[yt-dlp.git] / yt_dlp / 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'
4248dad9 13 _GEO_COUNTRIES = ['US', 'CA']
efef1714
JHJ
14 _TESTS = [{
15 'url': 'https://www.ondemandkorea.com/ask-us-anything-e43.html',
594601f5 16 'info_dict': {
17 'id': 'ask-us-anything-e43',
18 'ext': 'mp4',
efef1714
JHJ
19 'title': 'Ask Us Anything : Gain, Ji Soo - 09/24/2016',
20 'description': 'A talk show/game show with a school theme where celebrity guests appear as “transfer students.”',
ec85ded8 21 'thumbnail': r're:^https?://.*\.jpg$',
594601f5 22 },
23 'params': {
24 'skip_download': 'm3u8 download'
25 }
efef1714
JHJ
26 }, {
27 'url': 'https://www.ondemandkorea.com/confession-e01-1.html',
28 'info_dict': {
29 'id': 'confession-e01-1',
30 'ext': 'mp4',
31 'title': 'Confession : E01',
32 'description': 'Choi Do-hyun, a criminal attorney, is the son of a death row convict. Ever since Choi Pil-su got arrested for murder, Do-hyun has wanted to solve his ',
33 'thumbnail': r're:^https?://.*\.jpg$',
34 'subtitles': {
35 'English': 'mincount:1',
36 },
37 },
38 'params': {
39 'skip_download': 'm3u8 download'
40 }
41 }]
594601f5 42
43 def _real_extract(self, url):
44 video_id = self._match_id(url)
45 webpage = self._download_webpage(url, video_id, fatal=False)
46
47 if not webpage:
48 # Page sometimes returns captcha page with HTTP 403
47c914f9
S
49 raise ExtractorError(
50 'Unable to access page. You may have been blocked.',
51 expected=True)
594601f5 52
53 if 'msg_block_01.png' in webpage:
47c914f9 54 self.raise_geo_restricted(
01b1aa9f 55 msg='This content is not available in your region',
4248dad9 56 countries=self._GEO_COUNTRIES)
47c914f9 57
594601f5 58 if 'This video is only available to ODK PLUS members.' in webpage:
47c914f9
S
59 raise ExtractorError(
60 'This video is only available to ODK PLUS members.',
61 expected=True)
594601f5 62
abb41d64
JHJ
63 if 'ODK PREMIUM Members Only' in webpage:
64 raise ExtractorError(
65 'This video is only available to ODK PREMIUM members.',
66 expected=True)
67
efef1714
JHJ
68 title = self._search_regex(
69 r'class=["\']episode_title["\'][^>]*>([^<]+)',
70 webpage, 'episode_title', fatal=False) or self._og_search_title(webpage)
594601f5 71
47c914f9
S
72 jw_config = self._parse_json(
73 self._search_regex(
efef1714 74 r'(?s)odkPlayer\.init.*?(?P<options>{[^;]+}).*?;',
47c914f9
S
75 webpage, 'jw config', group='options'),
76 video_id, transform_source=js_to_json)
77 info = self._parse_jwplayer_data(
78 jw_config, video_id, require_title=False, m3u8_id='hls',
79 base_url=url)
594601f5 80
47c914f9 81 info.update({
594601f5 82 'title': title,
efef1714
JHJ
83 'description': self._og_search_description(webpage),
84 'thumbnail': self._og_search_thumbnail(webpage)
47c914f9
S
85 })
86 return info