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