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