2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
8 compat_urllib_parse_urlencode
,
16 class NaverIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:m\.)?tvcast\.naver\.com/v/(?P<id>\d+)'
20 'url': 'http://tvcast.naver.com/v/81652',
24 'title': '[9월 모의고사 해설강의][수학_김상희] 수학 A형 16~20번',
25 'description': '합격불변의 법칙 메가스터디 | 메가스터디 수학 김상희 선생님이 9월 모의고사 수학A형 16번에서 20번까지 해설강의를 공개합니다.',
26 'upload_date': '20130903',
29 'url': 'http://tvcast.naver.com/v/395837',
30 'md5': '638ed4c12012c458fefcddfd01f173cd',
34 'title': '9년이 지나도 아픈 기억, 전효성의 아버지',
35 'description': 'md5:5bf200dcbf4b66eb1b350d1eb9c753f7',
36 'upload_date': '20150519',
38 'skip': 'Georestricted',
41 def _real_extract(self
, url
):
42 video_id
= self
._match
_id
(url
)
43 webpage
= self
._download
_webpage
(url
, video_id
)
45 m_id
= re
.search(r
'var rmcPlayer = new nhn.rmcnmv.RMCVideoPlayer\("(.+?)", "(.+?)"',
48 error
= self
._html
_search
_regex
(
49 r
'(?s)<div class="(?:nation_error|nation_box|error_box)">\s*(?:<!--.*?-->)?\s*<p class="[^"]+">(?P<msg>.+?)</p>\s*</div>',
50 webpage
, 'error', default
=None)
52 raise ExtractorError(error
, expected
=True)
53 raise ExtractorError('couldn\'t extract vid and key')
56 query
= compat_urllib_parse_urlencode({'vid': vid
, 'inKey': key
, })
57 query_urls
= compat_urllib_parse_urlencode({
62 info
= self
._download
_xml
(
63 'http://serviceapi.rmcnmv.naver.com/flash/videoInfo.nhn?' + query
,
64 video_id
, 'Downloading video info')
65 urls
= self
._download
_xml
(
66 'http://serviceapi.rmcnmv.naver.com/flash/playableEncodingOption.nhn?' + query_urls
,
67 video_id
, 'Downloading video formats info')
70 for format_el
in urls
.findall('EncodingOptions/EncodingOption'):
71 domain
= format_el
.find('Domain').text
72 uri
= format_el
.find('uri').text
74 'url': compat_urlparse
.urljoin(domain
, uri
),
76 'width': int(format_el
.find('width').text
),
77 'height': int(format_el
.find('height').text
),
79 if domain
.startswith('rtmp'):
80 # urlparse does not support custom schemes
81 # https://bugs.python.org/issue18828
85 'rtmp_protocol': '1', # rtmpt
88 self
._sort
_formats
(formats
)
92 'title': info
.find('Subject').text
,
94 'description': self
._og
_search
_description
(webpage
),
95 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
96 'upload_date': info
.find('WriteDate').text
.replace('.', ''),
97 'view_count': int(info
.find('PlayCount').text
),