2021-12-20 05:02:48 +00:00
import re
2017-02-16 15:42:36 +00:00
from . common import InfoExtractor
2016-12-17 11:47:49 +00:00
from . . utils import (
ExtractorError ,
js_to_json ,
)
2016-09-27 05:29:21 +00:00
2017-02-16 15:42:36 +00:00
class OnDemandKoreaIE ( InfoExtractor ) :
2016-09-27 05:29:21 +00:00
_VALID_URL = r ' https?://(?:www \ .)?ondemandkorea \ .com/(?P<id>[^/]+) \ .html '
2017-02-18 20:53:23 +00:00
_GEO_COUNTRIES = [ ' US ' , ' CA ' ]
2020-07-02 19:53:54 +00:00
_TESTS = [ {
2022-09-28 09:04:03 +00:00
' url ' : ' https://www.ondemandkorea.com/ask-us-anything-e351.html ' ,
2016-09-27 05:29:21 +00:00
' info_dict ' : {
2022-09-28 09:04:03 +00:00
' id ' : ' ask-us-anything-e351 ' ,
2016-09-27 05:29:21 +00:00
' ext ' : ' mp4 ' ,
2022-09-28 09:04:03 +00:00
' title ' : ' Ask Us Anything : Jung Sung-ho, Park Seul-gi, Kim Bo-min, Yang Seung-won - 09/24/2022 ' ,
2020-07-02 19:53:54 +00:00
' description ' : ' A talk show/game show with a school theme where celebrity guests appear as “transfer students.” ' ,
2017-01-02 12:08:07 +00:00
' thumbnail ' : r ' re:^https?://.* \ .jpg$ ' ,
2016-09-27 05:29:21 +00:00
} ,
' params ' : {
' skip_download ' : ' m3u8 download '
}
2020-07-02 19:53:54 +00:00
} , {
2022-09-28 09:04:03 +00:00
' url ' : ' https://www.ondemandkorea.com/work-later-drink-now-e1.html ' ,
2020-07-02 19:53:54 +00:00
' info_dict ' : {
2022-09-28 09:04:03 +00:00
' id ' : ' work-later-drink-now-e1 ' ,
2020-07-02 19:53:54 +00:00
' ext ' : ' mp4 ' ,
2022-09-28 09:04:03 +00:00
' title ' : ' Work Later, Drink Now : E01 ' ,
' description ' : ' Work Later, Drink First follows three women who find solace in a glass of liquor at the end of the day. So-hee, who gets comfort from a cup of soju af ' ,
' thumbnail ' : r ' re:^https?://.* \ .png$ ' ,
2020-07-02 19:53:54 +00:00
' subtitles ' : {
' English ' : ' mincount:1 ' ,
} ,
} ,
' params ' : {
' skip_download ' : ' m3u8 download '
}
} ]
2016-09-27 05:29:21 +00:00
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 11:47:49 +00:00
raise ExtractorError (
' Unable to access page. You may have been blocked. ' ,
expected = True )
2016-09-27 05:29:21 +00:00
if ' msg_block_01.png ' in webpage :
2016-12-17 11:47:49 +00:00
self . raise_geo_restricted (
2017-02-04 11:52:11 +00:00
msg = ' This content is not available in your region ' ,
2017-02-18 20:53:23 +00:00
countries = self . _GEO_COUNTRIES )
2016-12-17 11:47:49 +00:00
2016-09-27 05:29:21 +00:00
if ' This video is only available to ODK PLUS members. ' in webpage :
2016-12-17 11:47:49 +00:00
raise ExtractorError (
' This video is only available to ODK PLUS members. ' ,
expected = True )
2016-09-27 05:29:21 +00:00
2020-08-02 18:59:18 +00:00
if ' ODK PREMIUM Members Only ' in webpage :
raise ExtractorError (
' This video is only available to ODK PREMIUM members. ' ,
expected = True )
2020-07-02 19:53:54 +00:00
title = self . _search_regex (
r ' class=[ " \' ]episode_title[ " \' ][^>]*>([^<]+) ' ,
webpage , ' episode_title ' , fatal = False ) or self . _og_search_title ( webpage )
2016-09-27 05:29:21 +00:00
2016-12-17 11:47:49 +00:00
jw_config = self . _parse_json (
2022-09-28 09:04:03 +00:00
self . _search_regex ( (
r ' (?P<options> { \ s*[ \' " ]tracks[ \' " ].*?})[) \ ];]+$ ' ,
2021-12-20 05:02:48 +00:00
r ' playlist \ s*= \ s* \ [(?P<options>.+)];?$ ' ,
2022-09-28 09:04:03 +00:00
r ' odkPlayer \ .init.*?(?P<options> { [^;]+}).*?; ' ,
) , webpage , ' jw config ' , flags = re . MULTILINE | re . DOTALL , group = ' options ' ) ,
2016-12-17 11:47:49 +00:00
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 05:29:21 +00:00
2016-12-17 11:47:49 +00:00
info . update ( {
2016-09-27 05:29:21 +00:00
' title ' : title ,
2020-07-02 19:53:54 +00:00
' description ' : self . _og_search_description ( webpage ) ,
' thumbnail ' : self . _og_search_thumbnail ( webpage )
2016-12-17 11:47:49 +00:00
} )
return info