]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/ondemandkorea.py
[ondemandkorea] fix jw_config regex extraction; change title and description extracti...
[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'
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
efef1714
JHJ
63 title = self._search_regex(
64 r'class=["\']episode_title["\'][^>]*>([^<]+)',
65 webpage, 'episode_title', fatal=False) or self._og_search_title(webpage)
594601f5 66
47c914f9
S
67 jw_config = self._parse_json(
68 self._search_regex(
efef1714 69 r'(?s)odkPlayer\.init.*?(?P<options>{[^;]+}).*?;',
47c914f9
S
70 webpage, 'jw config', group='options'),
71 video_id, transform_source=js_to_json)
72 info = self._parse_jwplayer_data(
73 jw_config, video_id, require_title=False, m3u8_id='hls',
74 base_url=url)
594601f5 75
47c914f9 76 info.update({
594601f5 77 'title': title,
efef1714
JHJ
78 'description': self._og_search_description(webpage),
79 'thumbnail': self._og_search_thumbnail(webpage)
47c914f9
S
80 })
81 return info