]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/naver.py
4 from .common
import InfoExtractor
11 class NaverIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://tvcast\.naver\.com/v/(?P<id>\d+)'
15 u
'url': u
'http://tvcast.naver.com/v/81652',
16 u
'file': u
'81652.mp4',
18 u
'title': u
'[9월 모의고사 해설강의][수학_김상희] 수학 A형 16~20번',
19 u
'description': u
'합격불변의 법칙 메가스터디 | 메가스터디 수학 김상희 선생님이 9월 모의고사 수학A형 16번에서 20번까지 해설강의를 공개합니다.',
20 u
'upload_date': u
'20130903',
24 def _real_extract(self
, url
):
25 mobj
= re
.match(self
._VALID
_URL
, url
)
26 video_id
= mobj
.group(1)
27 webpage
= self
._download
_webpage
(url
, video_id
)
28 m_id
= re
.search(r
'var rmcPlayer = new nhn.rmcnmv.RMCVideoPlayer\("(.+?)", "(.+?)"',
31 raise ExtractorError(u
'couldn\'t extract vid and key')
34 query
= compat_urllib_parse
.urlencode({'vid': vid
, 'inKey': key
,})
35 query_urls
= compat_urllib_parse
.urlencode({
40 info
= self
._download
_xml
(
41 'http://serviceapi.rmcnmv.naver.com/flash/videoInfo.nhn?' + query
,
42 video_id
, u
'Downloading video info')
43 urls
= self
._download
_xml
(
44 'http://serviceapi.rmcnmv.naver.com/flash/playableEncodingOption.nhn?' + query_urls
,
45 video_id
, u
'Downloading video formats info')
48 for format_el
in urls
.findall('EncodingOptions/EncodingOption'):
49 domain
= format_el
.find('Domain').text
50 if domain
.startswith('rtmp'):
53 'url': domain
+ format_el
.find('uri').text
,
55 'width': int(format_el
.find('width').text
),
56 'height': int(format_el
.find('height').text
),
61 'title': info
.find('Subject').text
,
63 'description': self
._og
_search
_description
(webpage
),
64 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
65 'upload_date': info
.find('WriteDate').text
.replace('.', ''),
66 'view_count': int(info
.find('PlayCount').text
),