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