]>
Commit | Line | Data |
---|---|---|
1 | import itertools | |
2 | ||
3 | from .common import InfoExtractor | |
4 | from ..compat import ( | |
5 | compat_urllib_parse_unquote, | |
6 | ) | |
7 | from ..utils import parse_qs | |
8 | ||
9 | ||
10 | class DaumBaseIE(InfoExtractor): | |
11 | _KAKAO_EMBED_BASE = 'http://tv.kakao.com/embed/player/cliplink/' | |
12 | ||
13 | ||
14 | class DaumIE(DaumBaseIE): | |
15 | _VALID_URL = r'https?://(?:(?:m\.)?tvpot\.daum\.net/v/|videofarm\.daum\.net/controller/player/VodPlayer\.swf\?vid=)(?P<id>[^?#&]+)' | |
16 | IE_NAME = 'daum.net' | |
17 | ||
18 | _TESTS = [{ | |
19 | 'url': 'http://tvpot.daum.net/v/vab4dyeDBysyBssyukBUjBz', | |
20 | 'info_dict': { | |
21 | 'id': 'vab4dyeDBysyBssyukBUjBz', | |
22 | 'ext': 'mp4', | |
23 | 'title': '마크 헌트 vs 안토니오 실바', | |
24 | 'description': 'Mark Hunt vs Antonio Silva', | |
25 | 'upload_date': '20131217', | |
26 | 'thumbnail': r're:^https?://.*\.(?:jpg|png)', | |
27 | 'duration': 2117, | |
28 | 'view_count': int, | |
29 | 'comment_count': int, | |
30 | 'uploader_id': 186139, | |
31 | 'uploader': '콘간지', | |
32 | 'timestamp': 1387310323, | |
33 | }, | |
34 | }, { | |
35 | 'url': 'http://m.tvpot.daum.net/v/65139429', | |
36 | 'info_dict': { | |
37 | 'id': '65139429', | |
38 | 'ext': 'mp4', | |
39 | 'title': '1297회, \'아빠 아들로 태어나길 잘 했어\' 민수, 감동의 눈물[아빠 어디가] 20150118', | |
40 | 'description': 'md5:79794514261164ff27e36a21ad229fc5', | |
41 | 'upload_date': '20150118', | |
42 | 'thumbnail': r're:^https?://.*\.(?:jpg|png)', | |
43 | 'duration': 154, | |
44 | 'view_count': int, | |
45 | 'comment_count': int, | |
46 | 'uploader': 'MBC 예능', | |
47 | 'uploader_id': 132251, | |
48 | 'timestamp': 1421604228, | |
49 | }, | |
50 | }, { | |
51 | 'url': 'http://tvpot.daum.net/v/07dXWRka62Y%24', | |
52 | 'only_matching': True, | |
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 )', | |
59 | 'description': 'Korean War 01\r\nTrouble on the horizon\r\n전쟁의 먹구름', | |
60 | 'upload_date': '20080223', | |
61 | 'thumbnail': r're:^https?://.*\.(?:jpg|png)', | |
62 | 'duration': 249, | |
63 | 'view_count': int, | |
64 | 'comment_count': int, | |
65 | 'uploader': '까칠한 墮落始祖 황비홍님의', | |
66 | 'uploader_id': 560824, | |
67 | 'timestamp': 1203770745, | |
68 | }, | |
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', | |
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, | |
82 | }, | |
83 | }] | |
84 | ||
85 | def _real_extract(self, url): | |
86 | video_id = compat_urllib_parse_unquote(self._match_id(url)) | |
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): | |
94 | _VALID_URL = r'https?://(?:m\.)?tvpot\.daum\.net/(?:clip/ClipView.(?:do|tv)|mypot/View.do)\?.*?clipid=(?P<id>\d+)' | |
95 | IE_NAME = 'daum.net:clip' | |
96 | _URL_TEMPLATE = 'http://tvpot.daum.net/clip/ClipView.do?clipid=%s' | |
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', | |
106 | 'thumbnail': r're:^https?://.*\.(?:jpg|png)', | |
107 | 'duration': 3868, | |
108 | 'view_count': int, | |
109 | 'uploader': 'GOMeXP', | |
110 | 'uploader_id': 6667, | |
111 | 'timestamp': 1377911092, | |
112 | }, | |
113 | }, { | |
114 | 'url': 'http://m.tvpot.daum.net/clip/ClipView.tv?clipid=54999425', | |
115 | 'only_matching': True, | |
116 | }] | |
117 | ||
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 | ||
122 | def _real_extract(self, url): | |
123 | video_id = self._match_id(url) | |
124 | return self.url_result( | |
125 | self._KAKAO_EMBED_BASE + video_id, 'Kakao', video_id) | |
126 | ||
127 | ||
128 | class DaumListIE(InfoExtractor): | |
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' % ( | |
135 | pagenum, list_id_type, list_id), list_id, 'Downloading list info - %s' % pagenum) | |
136 | ||
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 | ||
152 | def _check_clip(self, url, list_id): | |
153 | query_dict = parse_qs(url) | |
154 | if 'clipid' in query_dict: | |
155 | clip_id = query_dict['clipid'][0] | |
156 | if not self._yes_playlist(list_id, clip_id): | |
157 | return self.url_result(DaumClipIE._URL_TEMPLATE % clip_id, 'DaumClip') | |
158 | ||
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' | |
163 | _URL_TEMPLATE = 'http://tvpot.daum.net/mypot/View.do?playlistid=%s' | |
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 | ||
188 | @classmethod | |
189 | def suitable(cls, url): | |
190 | return False if DaumUserIE.suitable(url) else super(DaumPlaylistIE, cls).suitable(url) | |
191 | ||
192 | def _real_extract(self, url): | |
193 | list_id = self._match_id(url) | |
194 | ||
195 | clip_result = self._check_clip(url, list_id) | |
196 | if clip_result: | |
197 | return clip_result | |
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): | |
205 | _VALID_URL = r'https?://(?:m\.)?tvpot\.daum\.net/mypot/(?:View|Top)\.(?:do|tv)\?.*?ownerid=(?P<id>[0-9a-zA-Z]+)' | |
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, | |
239 | }, { | |
240 | 'url': 'http://m.tvpot.daum.net/mypot/Top.tv?ownerid=45x1okb1If50&playlistid=3569733', | |
241 | 'only_matching': True, | |
242 | }] | |
243 | ||
244 | def _real_extract(self, url): | |
245 | list_id = self._match_id(url) | |
246 | ||
247 | clip_result = self._check_clip(url, list_id) | |
248 | if clip_result: | |
249 | return clip_result | |
250 | ||
251 | query_dict = parse_qs(url) | |
252 | if 'playlistid' in query_dict: | |
253 | playlist_id = query_dict['playlistid'][0] | |
254 | return self.url_result(DaumPlaylistIE._URL_TEMPLATE % playlist_id, 'DaumPlaylist') | |
255 | ||
256 | name, entries = self._get_entries(list_id, 'ownerid') | |
257 | ||
258 | return self.playlist_result(entries, list_id, name) |