]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/naver.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class NaverIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:m\.)?tvcast\.naver\.com/v/(?P<id>\d+)'
18 'url': 'http://tvcast.naver.com/v/81652',
22 'title': '[9월 모의고사 해설강의][수학_김상희] 수학 A형 16~20번',
23 'description': '합격불변의 법칙 메가스터디 | 메가스터디 수학 김상희 선생님이 9월 모의고사 수학A형 16번에서 20번까지 해설강의를 공개합니다.',
24 'upload_date': '20130903',
28 def _real_extract(self
, url
):
29 mobj
= re
.match(self
._VALID
_URL
, url
)
30 video_id
= mobj
.group(1)
31 webpage
= self
._download
_webpage
(url
, video_id
)
32 m_id
= re
.search(r
'var rmcPlayer = new nhn.rmcnmv.RMCVideoPlayer\("(.+?)", "(.+?)"',
36 r
'(?s)<div class="nation_error">\s*(?:<!--.*?-->)?\s*<p class="[^"]+">(?P<msg>.+?)</p>\s*</div>',
39 raise ExtractorError(clean_html(m_error
.group('msg')), expected
=True)
40 raise ExtractorError('couldn\'t extract vid and key')
43 query
= compat_urllib_parse
.urlencode({'vid': vid
, 'inKey': key
,})
44 query_urls
= compat_urllib_parse
.urlencode({
49 info
= self
._download
_xml
(
50 'http://serviceapi.rmcnmv.naver.com/flash/videoInfo.nhn?' + query
,
51 video_id
, 'Downloading video info')
52 urls
= self
._download
_xml
(
53 'http://serviceapi.rmcnmv.naver.com/flash/playableEncodingOption.nhn?' + query_urls
,
54 video_id
, 'Downloading video formats info')
57 for format_el
in urls
.findall('EncodingOptions/EncodingOption'):
58 domain
= format_el
.find('Domain').text
60 'url': domain
+ format_el
.find('uri').text
,
62 'width': int(format_el
.find('width').text
),
63 'height': int(format_el
.find('height').text
),
65 if domain
.startswith('rtmp'):
68 'rtmp_protocol': '1', # rtmpt
71 self
._sort
_formats
(formats
)
75 'title': info
.find('Subject').text
,
77 'description': self
._og
_search
_description
(webpage
),
78 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
79 'upload_date': info
.find('WriteDate').text
.replace('.', ''),
80 'view_count': int(info
.find('PlayCount').text
),