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