]>
Commit | Line | Data |
---|---|---|
150f2082 | 1 | # encoding: utf-8 |
23f4a93b PH |
2 | |
3 | from __future__ import unicode_literals | |
4 | ||
150f2082 | 5 | from .common import InfoExtractor |
72033465 | 6 | from ..compat import compat_urllib_parse |
126d7701 | 7 | from ..utils import ( |
8 | int_or_none, | |
9 | str_to_int, | |
10 | xpath_text, | |
150f2082 JMF |
11 | ) |
12 | ||
13 | ||
14 | class DaumIE(InfoExtractor): | |
72033465 | 15 | _VALID_URL = r'https?://(?:m\.)?tvpot\.daum\.net/v/(?P<id>[^?#&]+)' |
23f4a93b | 16 | IE_NAME = 'daum.net' |
150f2082 | 17 | |
e5a79071 | 18 | _TESTS = [{ |
72033465 | 19 | 'url': 'http://tvpot.daum.net/v/vab4dyeDBysyBssyukBUjBz', |
178b47e6 | 20 | 'info_dict': { |
72033465 | 21 | 'id': 'vab4dyeDBysyBssyukBUjBz', |
178b47e6 | 22 | 'ext': 'mp4', |
72033465 | 23 | 'title': '마크 헌트 vs 안토니오 실바', |
24 | 'description': 'Mark Hunt vs Antonio Silva', | |
25 | 'upload_date': '20131217', | |
26 | 'duration': 2117, | |
126d7701 | 27 | 'view_count': int, |
28 | 'comment_count': int, | |
178b47e6 | 29 | }, |
e5a79071 PH |
30 | }, { |
31 | 'url': 'http://tvpot.daum.net/v/07dXWRka62Y%24', | |
32 | 'only_matching': True, | |
33 | }] | |
150f2082 JMF |
34 | |
35 | def _real_extract(self, url): | |
72033465 | 36 | video_id = self._match_id(url) |
37 | query = compat_urllib_parse.urlencode({'vid': video_id}) | |
e26f8712 | 38 | info = self._download_xml( |
150f2082 | 39 | 'http://tvpot.daum.net/clip/ClipInfoXml.do?' + query, video_id, |
23f4a93b | 40 | 'Downloading video info') |
72033465 | 41 | movie_data = self._download_json( |
42 | 'http://videofarm.daum.net/controller/api/closed/v1_2/IntegratedMovieData.json?' + query, | |
23f4a93b | 43 | video_id, 'Downloading video formats info') |
150f2082 | 44 | |
150f2082 | 45 | formats = [] |
72033465 | 46 | for format_el in movie_data['output_list']['output_list']: |
47 | profile = format_el['profile'] | |
150f2082 | 48 | format_query = compat_urllib_parse.urlencode({ |
72033465 | 49 | 'vid': video_id, |
150f2082 JMF |
50 | 'profile': profile, |
51 | }) | |
e26f8712 | 52 | url_doc = self._download_xml( |
150f2082 | 53 | 'http://videofarm.daum.net/controller/api/open/v1_2/MovieLocation.apixml?' + format_query, |
e5a79071 | 54 | video_id, note='Downloading video data for %s format' % profile) |
150f2082 JMF |
55 | format_url = url_doc.find('result/url').text |
56 | formats.append({ | |
57 | 'url': format_url, | |
150f2082 | 58 | 'format_id': profile, |
72033465 | 59 | 'width': int_or_none(format_el.get('width')), |
60 | 'height': int_or_none(format_el.get('height')), | |
61 | 'filesize': int_or_none(format_el.get('filesize')), | |
150f2082 | 62 | }) |
72033465 | 63 | self._sort_formats(formats) |
150f2082 | 64 | |
fb7abb31 | 65 | return { |
150f2082 JMF |
66 | 'id': video_id, |
67 | 'title': info.find('TITLE').text, | |
68 | 'formats': formats, | |
126d7701 | 69 | 'thumbnail': xpath_text(info, 'THUMB_URL'), |
70 | 'description': xpath_text(info, 'CONTENTS'), | |
71 | 'duration': int_or_none(xpath_text(info, 'DURATION')), | |
150f2082 | 72 | 'upload_date': info.find('REGDTTM').text[:8], |
126d7701 | 73 | 'view_count': str_to_int(xpath_text(info, 'PLAY_CNT')), |
74 | 'comment_count': str_to_int(xpath_text(info, 'COMMENT_CNT')), | |
150f2082 | 75 | } |
72033465 | 76 | |
77 | ||
78 | class DaumClipIE(InfoExtractor): | |
126d7701 | 79 | _VALID_URL = r'https?://(?:m\.)?tvpot\.daum\.net/(?:clip/ClipView.do|mypot/View.do)\?.*?clipid=(?P<id>\d+)' |
db710571 | 80 | IE_NAME = 'daum.net:clip' |
72033465 | 81 | |
82 | _TESTS = [{ | |
83 | 'url': 'http://tvpot.daum.net/clip/ClipView.do?clipid=52554690', | |
84 | 'info_dict': { | |
85 | 'id': '52554690', | |
86 | 'ext': 'mp4', | |
87 | 'title': 'DOTA 2GETHER 시즌2 6회 - 2부', | |
88 | 'description': 'DOTA 2GETHER 시즌2 6회 - 2부', | |
89 | 'upload_date': '20130831', | |
90 | 'duration': 3868, | |
91 | 'view_count': int, | |
92 | }, | |
93 | }] | |
94 | ||
95 | def _real_extract(self, url): | |
96 | video_id = self._match_id(url) | |
126d7701 | 97 | clip_info = self._download_json( |
98 | 'http://tvpot.daum.net/mypot/json/GetClipInfo.do?clipid=%s' % video_id, | |
99 | video_id, 'Downloading clip info')['clip_bean'] | |
72033465 | 100 | |
101 | return { | |
102 | '_type': 'url_transparent', | |
103 | 'id': video_id, | |
104 | 'url': 'http://tvpot.daum.net/v/%s' % clip_info['vid'], | |
105 | 'title': clip_info['title'], | |
106 | 'thumbnail': clip_info.get('thumb_url'), | |
107 | 'description': clip_info.get('contents'), | |
108 | 'duration': int_or_none(clip_info.get('duration')), | |
109 | 'upload_date': clip_info.get('up_date')[:8], | |
110 | 'view_count': int_or_none(clip_info.get('play_count')), | |
111 | 'ie_key': 'Daum', | |
150f2082 | 112 | } |