]>
Commit | Line | Data |
---|---|---|
150f2082 JMF |
1 | # encoding: utf-8 |
2 | import re | |
150f2082 JMF |
3 | |
4 | from .common import InfoExtractor | |
5 | from ..utils import ( | |
6 | compat_urllib_parse, | |
7 | determine_ext, | |
8 | ) | |
9 | ||
10 | ||
11 | class DaumIE(InfoExtractor): | |
7a563df9 | 12 | _VALID_URL = r'https?://(?:m\.)?tvpot\.daum\.net/.*?clipid=(?P<id>\d+)' |
150f2082 JMF |
13 | IE_NAME = u'daum.net' |
14 | ||
15 | _TEST = { | |
16 | u'url': u'http://tvpot.daum.net/clip/ClipView.do?clipid=52554690', | |
17 | u'file': u'52554690.mp4', | |
18 | u'info_dict': { | |
19 | u'title': u'DOTA 2GETHER 시즌2 6회 - 2부', | |
9363169b | 20 | u'description': u'DOTA 2GETHER 시즌2 6회 - 2부', |
150f2082 JMF |
21 | u'upload_date': u'20130831', |
22 | u'duration': 3868, | |
23 | }, | |
24 | } | |
25 | ||
26 | def _real_extract(self, url): | |
27 | mobj = re.match(self._VALID_URL, url) | |
28 | video_id = mobj.group(1) | |
9363169b JMF |
29 | canonical_url = 'http://tvpot.daum.net/v/%s' % video_id |
30 | webpage = self._download_webpage(canonical_url, video_id) | |
ce93879a PH |
31 | full_id = self._search_regex( |
32 | r'<iframe src="http://videofarm.daum.net/controller/video/viewer/Video.html\?.*?vid=(.+?)[&"]', | |
150f2082 JMF |
33 | webpage, u'full id') |
34 | query = compat_urllib_parse.urlencode({'vid': full_id}) | |
e26f8712 | 35 | info = self._download_xml( |
150f2082 JMF |
36 | 'http://tvpot.daum.net/clip/ClipInfoXml.do?' + query, video_id, |
37 | u'Downloading video info') | |
e26f8712 | 38 | urls = self._download_xml( |
150f2082 JMF |
39 | 'http://videofarm.daum.net/controller/api/open/v1_2/MovieData.apixml?' + query, |
40 | video_id, u'Downloading video formats info') | |
150f2082 JMF |
41 | |
42 | self.to_screen(u'%s: Getting video urls' % video_id) | |
43 | formats = [] | |
44 | for format_el in urls.findall('result/output_list/output_list'): | |
45 | profile = format_el.attrib['profile'] | |
46 | format_query = compat_urllib_parse.urlencode({ | |
47 | 'vid': full_id, | |
48 | 'profile': profile, | |
49 | }) | |
e26f8712 | 50 | url_doc = self._download_xml( |
150f2082 JMF |
51 | 'http://videofarm.daum.net/controller/api/open/v1_2/MovieLocation.apixml?' + format_query, |
52 | video_id, note=False) | |
150f2082 JMF |
53 | format_url = url_doc.find('result/url').text |
54 | formats.append({ | |
55 | 'url': format_url, | |
56 | 'ext': determine_ext(format_url), | |
57 | 'format_id': profile, | |
58 | }) | |
59 | ||
fb7abb31 | 60 | return { |
150f2082 JMF |
61 | 'id': video_id, |
62 | 'title': info.find('TITLE').text, | |
63 | 'formats': formats, | |
64 | 'thumbnail': self._og_search_thumbnail(webpage), | |
9363169b | 65 | 'description': info.find('CONTENTS').text, |
150f2082 JMF |
66 | 'duration': int(info.find('DURATION').text), |
67 | 'upload_date': info.find('REGDTTM').text[:8], | |
68 | } |