]>
Commit | Line | Data |
---|---|---|
e0317686 KH |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
5 | from ..utils import ( | |
6 | int_or_none, | |
7 | parse_duration, | |
8 | parse_iso8601, | |
9 | ) | |
10 | ||
11 | ||
12 | class MnetIE(InfoExtractor): | |
13 | _VALID_URL = r'https?://(?:www\.)?mnet\.(?:com|interest\.me)/tv/vod/(?:.*?\bclip_id=)?(?P<id>[0-9]+)' | |
14 | _TESTS = [ | |
15 | { | |
16 | 'url': 'http://www.mnet.com/tv/vod/171008', | |
17 | 'md5': '6abd7a837fa9fe56d22709a60b19bffb', | |
18 | 'info_dict': { | |
19 | 'id': '171008', | |
20 | 'title': 'SS_이해인@히든박스', | |
21 | 'description': 'md5:b9efa592c3918b615ba69fe9f8a05c55', | |
22 | 'duration': 88, | |
23 | 'upload_date': '20151231', | |
24 | 'timestamp': 1451564040, | |
25 | 'age_limit': 0, | |
26 | 'thumbnails': 'mincount:5', | |
27 | 'ext': 'flv', | |
28 | }, | |
29 | }, | |
30 | { | |
31 | 'url': 'http://mnet.interest.me/tv/vod/172790', | |
32 | 'only_matching': True, | |
33 | }, | |
34 | { | |
35 | 'url': 'http://www.mnet.com/tv/vod/vod_view.asp?clip_id=172790&tabMenu=', | |
36 | 'only_matching': True, | |
37 | }, | |
38 | ] | |
39 | ||
40 | def _real_extract(self, url): | |
41 | video_id = self._match_id(url) | |
42 | info_url = 'http://content.api.mnet.com/player/vodConfig?id=%s' % video_id | |
43 | info = self._download_json(info_url, video_id) | |
44 | info = info['data']['info'] | |
45 | ||
46 | title = info['title'] | |
47 | rtmp_info_url = info['cdn'] + 'CLIP' | |
48 | rtmp_info = self._download_json(rtmp_info_url, video_id) | |
49 | file_url = rtmp_info['serverurl'] + rtmp_info['fileurl'] | |
50 | description = info.get('ment') | |
51 | duration = parse_duration(info.get('time')) | |
52 | timestamp = parse_iso8601(info.get('date'), delimiter=' ') | |
53 | age_limit = info.get('adult') | |
54 | if age_limit is not None: | |
55 | age_limit = 0 if age_limit == 'N' else 18 | |
56 | thumbnails = [ | |
57 | { | |
58 | 'id': thumb_format, | |
59 | 'url': thumb['url'], | |
60 | 'width': int_or_none(thumb.get('width')), | |
61 | 'height': int_or_none(thumb.get('height')), | |
62 | } | |
63 | for (thumb_format, thumb) in info.get('cover', {}).items() | |
64 | ] | |
65 | ||
66 | return { | |
67 | 'id': video_id, | |
68 | 'title': title, | |
69 | 'url': file_url, | |
70 | 'description': description, | |
71 | 'duration': duration, | |
72 | 'timestamp': timestamp, | |
73 | 'age_limit': age_limit, | |
74 | 'thumbnails': thumbnails, | |
75 | 'ext': 'flv', | |
76 | } |