]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/naver.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
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',
30 def _real_extract(self
, url
):
31 video_id
= self
._match
_id
(url
)
32 webpage
= self
._download
_webpage
(url
, video_id
)
34 m_id
= re
.search(r
'var rmcPlayer = new nhn.rmcnmv.RMCVideoPlayer\("(.+?)", "(.+?)"',
38 r
'(?s)<div class="nation_error">\s*(?:<!--.*?-->)?\s*<p class="[^"]+">(?P<msg>.+?)</p>\s*</div>',
41 raise ExtractorError(clean_html(m_error
.group('msg')), expected
=True)
42 raise ExtractorError('couldn\'t extract vid and key')
45 query
= compat_urllib_parse
.urlencode({'vid': vid
, 'inKey': key
, })
46 query_urls
= compat_urllib_parse
.urlencode({
51 info
= self
._download
_xml
(
52 'http://serviceapi.rmcnmv.naver.com/flash/videoInfo.nhn?' + query
,
53 video_id
, 'Downloading video info')
54 urls
= self
._download
_xml
(
55 'http://serviceapi.rmcnmv.naver.com/flash/playableEncodingOption.nhn?' + query_urls
,
56 video_id
, 'Downloading video formats info')
59 for format_el
in urls
.findall('EncodingOptions/EncodingOption'):
60 domain
= format_el
.find('Domain').text
62 'url': domain
+ format_el
.find('uri').text
,
64 'width': int(format_el
.find('width').text
),
65 'height': int(format_el
.find('height').text
),
67 if domain
.startswith('rtmp'):
70 'rtmp_protocol': '1', # rtmpt
73 self
._sort
_formats
(formats
)
77 'title': info
.find('Subject').text
,
79 'description': self
._og
_search
_description
(webpage
),
80 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
81 'upload_date': info
.find('WriteDate').text
.replace('.', ''),
82 'view_count': int(info
.find('PlayCount').text
),