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