]>
Commit | Line | Data |
---|---|---|
dcdb292f | 1 | # coding: utf-8 |
23f4a93b PH |
2 | |
3 | from __future__ import unicode_literals | |
4 | ||
2f0a33d8 | 5 | import itertools |
b6c33fd5 | 6 | |
150f2082 | 7 | from .common import InfoExtractor |
830afe85 | 8 | from ..compat import ( |
11a4efc5 | 9 | compat_parse_qs, |
830afe85 | 10 | compat_urllib_parse_unquote, |
11a4efc5 | 11 | compat_urlparse, |
830afe85 | 12 | ) |
150f2082 JMF |
13 | |
14 | ||
d4399892 RA |
15 | class DaumBaseIE(InfoExtractor): |
16 | _KAKAO_EMBED_BASE = 'http://tv.kakao.com/embed/player/cliplink/' | |
17 | ||
18 | ||
19 | class DaumIE(DaumBaseIE): | |
830afe85 | 20 | _VALID_URL = r'https?://(?:(?:m\.)?tvpot\.daum\.net/v/|videofarm\.daum\.net/controller/player/VodPlayer\.swf\?vid=)(?P<id>[^?#&]+)' |
23f4a93b | 21 | IE_NAME = 'daum.net' |
150f2082 | 22 | |
e5a79071 | 23 | _TESTS = [{ |
72033465 | 24 | 'url': 'http://tvpot.daum.net/v/vab4dyeDBysyBssyukBUjBz', |
178b47e6 | 25 | 'info_dict': { |
72033465 | 26 | 'id': 'vab4dyeDBysyBssyukBUjBz', |
178b47e6 | 27 | 'ext': 'mp4', |
72033465 | 28 | 'title': '마크 헌트 vs 안토니오 실바', |
29 | 'description': 'Mark Hunt vs Antonio Silva', | |
30 | 'upload_date': '20131217', | |
ec85ded8 | 31 | 'thumbnail': r're:^https?://.*\.(?:jpg|png)', |
72033465 | 32 | 'duration': 2117, |
126d7701 | 33 | 'view_count': int, |
34 | 'comment_count': int, | |
d4399892 RA |
35 | 'uploader_id': 186139, |
36 | 'uploader': '콘간지', | |
37 | 'timestamp': 1387310323, | |
178b47e6 | 38 | }, |
e5a79071 | 39 | }, { |
b6c33fd5 | 40 | 'url': 'http://m.tvpot.daum.net/v/65139429', |
41 | 'info_dict': { | |
42 | 'id': '65139429', | |
43 | 'ext': 'mp4', | |
58250eff | 44 | 'title': '1297회, \'아빠 아들로 태어나길 잘 했어\' 민수, 감동의 눈물[아빠 어디가] 20150118', |
b6c33fd5 | 45 | 'description': 'md5:79794514261164ff27e36a21ad229fc5', |
d4399892 | 46 | 'upload_date': '20150118', |
ec85ded8 | 47 | 'thumbnail': r're:^https?://.*\.(?:jpg|png)', |
f5d30d52 | 48 | 'duration': 154, |
49 | 'view_count': int, | |
50 | 'comment_count': int, | |
d4399892 RA |
51 | 'uploader': 'MBC 예능', |
52 | 'uploader_id': 132251, | |
53 | 'timestamp': 1421604228, | |
e047922b | 54 | }, |
55 | }, { | |
e5a79071 PH |
56 | 'url': 'http://tvpot.daum.net/v/07dXWRka62Y%24', |
57 | 'only_matching': True, | |
830afe85 YCH |
58 | }, { |
59 | 'url': 'http://videofarm.daum.net/controller/player/VodPlayer.swf?vid=vwIpVpCQsT8%24&ref=', | |
60 | 'info_dict': { | |
61 | 'id': 'vwIpVpCQsT8$', | |
62 | 'ext': 'flv', | |
63 | 'title': '01-Korean War ( Trouble on the horizon )', | |
d4399892 | 64 | 'description': 'Korean War 01\r\nTrouble on the horizon\r\n전쟁의 먹구름', |
830afe85 | 65 | 'upload_date': '20080223', |
ec85ded8 | 66 | 'thumbnail': r're:^https?://.*\.(?:jpg|png)', |
830afe85 YCH |
67 | 'duration': 249, |
68 | 'view_count': int, | |
69 | 'comment_count': int, | |
d4399892 RA |
70 | 'uploader': '까칠한 墮落始祖 황비홍님의', |
71 | 'uploader_id': 560824, | |
72 | 'timestamp': 1203770745, | |
830afe85 | 73 | }, |
f7291a0b YCH |
74 | }, { |
75 | # Requires dte_type=WEB (#9972) | |
76 | 'url': 'http://tvpot.daum.net/v/s3794Uf1NZeZ1qMpGpeqeRU', | |
77 | 'md5': 'a8917742069a4dd442516b86e7d66529', | |
78 | 'info_dict': { | |
79 | 'id': 's3794Uf1NZeZ1qMpGpeqeRU', | |
80 | 'ext': 'mp4', | |
d4399892 RA |
81 | 'title': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)', |
82 | 'description': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)\r\n\r\n[쇼! 음악중심] 20160611, 507회', | |
83 | 'upload_date': '20170129', | |
84 | 'uploader': '쇼! 음악중심', | |
85 | 'uploader_id': 2653210, | |
86 | 'timestamp': 1485684628, | |
f7291a0b | 87 | }, |
e5a79071 | 88 | }] |
150f2082 JMF |
89 | |
90 | def _real_extract(self, url): | |
830afe85 | 91 | video_id = compat_urllib_parse_unquote(self._match_id(url)) |
d4399892 RA |
92 | if not video_id.isdigit(): |
93 | video_id += '@my' | |
94 | return self.url_result( | |
95 | self._KAKAO_EMBED_BASE + video_id, 'Kakao', video_id) | |
96 | ||
97 | ||
98 | class DaumClipIE(DaumBaseIE): | |
b6c33fd5 | 99 | _VALID_URL = r'https?://(?:m\.)?tvpot\.daum\.net/(?:clip/ClipView.(?:do|tv)|mypot/View.do)\?.*?clipid=(?P<id>\d+)' |
db710571 | 100 | IE_NAME = 'daum.net:clip' |
11a4efc5 | 101 | _URL_TEMPLATE = 'http://tvpot.daum.net/clip/ClipView.do?clipid=%s' |
72033465 | 102 | |
103 | _TESTS = [{ | |
104 | 'url': 'http://tvpot.daum.net/clip/ClipView.do?clipid=52554690', | |
105 | 'info_dict': { | |
106 | 'id': '52554690', | |
107 | 'ext': 'mp4', | |
108 | 'title': 'DOTA 2GETHER 시즌2 6회 - 2부', | |
109 | 'description': 'DOTA 2GETHER 시즌2 6회 - 2부', | |
110 | 'upload_date': '20130831', | |
ec85ded8 | 111 | 'thumbnail': r're:^https?://.*\.(?:jpg|png)', |
72033465 | 112 | 'duration': 3868, |
113 | 'view_count': int, | |
d4399892 RA |
114 | 'uploader': 'GOMeXP', |
115 | 'uploader_id': 6667, | |
116 | 'timestamp': 1377911092, | |
72033465 | 117 | }, |
b6c33fd5 | 118 | }, { |
119 | 'url': 'http://m.tvpot.daum.net/clip/ClipView.tv?clipid=54999425', | |
120 | 'only_matching': True, | |
72033465 | 121 | }] |
122 | ||
11a4efc5 YCH |
123 | @classmethod |
124 | def suitable(cls, url): | |
125 | return False if DaumPlaylistIE.suitable(url) or DaumUserIE.suitable(url) else super(DaumClipIE, cls).suitable(url) | |
126 | ||
72033465 | 127 | def _real_extract(self, url): |
128 | video_id = self._match_id(url) | |
d4399892 RA |
129 | return self.url_result( |
130 | self._KAKAO_EMBED_BASE + video_id, 'Kakao', video_id) | |
2f0a33d8 | 131 | |
132 | ||
133 | class DaumListIE(InfoExtractor): | |
134 | def _get_entries(self, list_id, list_id_type): | |
135 | name = None | |
136 | entries = [] | |
137 | for pagenum in itertools.count(1): | |
138 | list_info = self._download_json( | |
139 | 'http://tvpot.daum.net/mypot/json/GetClipInfo.do?size=48&init=true&order=date&page=%d&%s=%s' % ( | |
7537b35f YCH |
140 | pagenum, list_id_type, list_id), list_id, 'Downloading list info - %s' % pagenum) |
141 | ||
2f0a33d8 | 142 | entries.extend([ |
143 | self.url_result( | |
144 | 'http://tvpot.daum.net/v/%s' % clip['vid']) | |
145 | for clip in list_info['clip_list'] | |
146 | ]) | |
147 | ||
148 | if not name: | |
149 | name = list_info.get('playlist_bean', {}).get('name') or \ | |
150 | list_info.get('potInfo', {}).get('name') | |
151 | ||
152 | if not list_info.get('has_more'): | |
153 | break | |
154 | ||
155 | return name, entries | |
156 | ||
11a4efc5 YCH |
157 | def _check_clip(self, url, list_id): |
158 | query_dict = compat_parse_qs(compat_urlparse.urlparse(url).query) | |
159 | if 'clipid' in query_dict: | |
160 | clip_id = query_dict['clipid'][0] | |
161 | if self._downloader.params.get('noplaylist'): | |
162 | self.to_screen('Downloading just video %s because of --no-playlist' % clip_id) | |
163 | return self.url_result(DaumClipIE._URL_TEMPLATE % clip_id, 'DaumClip') | |
164 | else: | |
165 | self.to_screen('Downloading playlist %s - add --no-playlist to just download video' % list_id) | |
166 | ||
2f0a33d8 | 167 | |
168 | class DaumPlaylistIE(DaumListIE): | |
169 | _VALID_URL = r'https?://(?:m\.)?tvpot\.daum\.net/mypot/(?:View\.do|Top\.tv)\?.*?playlistid=(?P<id>[0-9]+)' | |
170 | IE_NAME = 'daum.net:playlist' | |
11a4efc5 | 171 | _URL_TEMPLATE = 'http://tvpot.daum.net/mypot/View.do?playlistid=%s' |
2f0a33d8 | 172 | |
173 | _TESTS = [{ | |
174 | 'note': 'Playlist url with clipid', | |
175 | 'url': 'http://tvpot.daum.net/mypot/View.do?playlistid=6213966&clipid=73806844', | |
176 | 'info_dict': { | |
177 | 'id': '6213966', | |
178 | 'title': 'Woorissica Official', | |
179 | }, | |
180 | 'playlist_mincount': 181 | |
181 | }, { | |
182 | 'note': 'Playlist url with clipid - noplaylist', | |
183 | 'url': 'http://tvpot.daum.net/mypot/View.do?playlistid=6213966&clipid=73806844', | |
184 | 'info_dict': { | |
185 | 'id': '73806844', | |
186 | 'ext': 'mp4', | |
187 | 'title': '151017 Airport', | |
188 | 'upload_date': '20160117', | |
189 | }, | |
190 | 'params': { | |
191 | 'noplaylist': True, | |
192 | 'skip_download': True, | |
193 | } | |
194 | }] | |
195 | ||
11a4efc5 YCH |
196 | @classmethod |
197 | def suitable(cls, url): | |
198 | return False if DaumUserIE.suitable(url) else super(DaumPlaylistIE, cls).suitable(url) | |
2f0a33d8 | 199 | |
11a4efc5 | 200 | def _real_extract(self, url): |
2f0a33d8 | 201 | list_id = self._match_id(url) |
11a4efc5 YCH |
202 | |
203 | clip_result = self._check_clip(url, list_id) | |
204 | if clip_result: | |
205 | return clip_result | |
2f0a33d8 | 206 | |
207 | name, entries = self._get_entries(list_id, 'playlistid') | |
208 | ||
209 | return self.playlist_result(entries, list_id, name) | |
210 | ||
211 | ||
212 | class DaumUserIE(DaumListIE): | |
dc724e0c | 213 | _VALID_URL = r'https?://(?:m\.)?tvpot\.daum\.net/mypot/(?:View|Top)\.(?:do|tv)\?.*?ownerid=(?P<id>[0-9a-zA-Z]+)' |
2f0a33d8 | 214 | IE_NAME = 'daum.net:user' |
215 | ||
216 | _TESTS = [{ | |
217 | 'url': 'http://tvpot.daum.net/mypot/View.do?ownerid=o2scDLIVbHc0', | |
218 | 'info_dict': { | |
219 | 'id': 'o2scDLIVbHc0', | |
220 | 'title': '마이 리틀 텔레비전', | |
221 | }, | |
222 | 'playlist_mincount': 213 | |
223 | }, { | |
224 | 'url': 'http://tvpot.daum.net/mypot/View.do?ownerid=o2scDLIVbHc0&clipid=73801156', | |
225 | 'info_dict': { | |
226 | 'id': '73801156', | |
227 | 'ext': 'mp4', | |
228 | 'title': '[미공개] 김구라, 오만석이 부릅니다 \'오케피\' - 마이 리틀 텔레비전 20160116', | |
229 | 'upload_date': '20160117', | |
230 | 'description': 'md5:5e91d2d6747f53575badd24bd62b9f36' | |
231 | }, | |
232 | 'params': { | |
233 | 'noplaylist': True, | |
234 | 'skip_download': True, | |
235 | } | |
236 | }, { | |
237 | 'note': 'Playlist url has ownerid and playlistid, playlistid takes precedence', | |
238 | 'url': 'http://tvpot.daum.net/mypot/View.do?ownerid=o2scDLIVbHc0&playlistid=6196631', | |
239 | 'info_dict': { | |
240 | 'id': '6196631', | |
241 | 'title': '마이 리틀 텔레비전 - 20160109', | |
242 | }, | |
243 | 'playlist_count': 11 | |
244 | }, { | |
245 | 'url': 'http://tvpot.daum.net/mypot/Top.do?ownerid=o2scDLIVbHc0', | |
246 | 'only_matching': True, | |
dc724e0c YCH |
247 | }, { |
248 | 'url': 'http://m.tvpot.daum.net/mypot/Top.tv?ownerid=45x1okb1If50&playlistid=3569733', | |
249 | 'only_matching': True, | |
2f0a33d8 | 250 | }] |
251 | ||
252 | def _real_extract(self, url): | |
11a4efc5 | 253 | list_id = self._match_id(url) |
2f0a33d8 | 254 | |
11a4efc5 YCH |
255 | clip_result = self._check_clip(url, list_id) |
256 | if clip_result: | |
257 | return clip_result | |
258 | ||
259 | query_dict = compat_parse_qs(compat_urlparse.urlparse(url).query) | |
260 | if 'playlistid' in query_dict: | |
261 | playlist_id = query_dict['playlistid'][0] | |
262 | return self.url_result(DaumPlaylistIE._URL_TEMPLATE % playlist_id, 'DaumPlaylist') | |
2f0a33d8 | 263 | |
2f0a33d8 | 264 | name, entries = self._get_entries(list_id, 'ownerid') |
265 | ||
266 | return self.playlist_result(entries, list_id, name) |