]>
Commit | Line | Data |
---|---|---|
e0317686 KH |
1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
3 | int_or_none, | |
4 | parse_duration, | |
5 | parse_iso8601, | |
6 | ) | |
7 | ||
8 | ||
9 | class MnetIE(InfoExtractor): | |
10 | _VALID_URL = r'https?://(?:www\.)?mnet\.(?:com|interest\.me)/tv/vod/(?:.*?\bclip_id=)?(?P<id>[0-9]+)' | |
98e68806 S |
11 | _TESTS = [{ |
12 | 'url': 'http://www.mnet.com/tv/vod/171008', | |
13 | 'info_dict': { | |
14 | 'id': '171008', | |
15 | 'title': 'SS_이해인@히든박스', | |
16 | 'description': 'md5:b9efa592c3918b615ba69fe9f8a05c55', | |
17 | 'duration': 88, | |
18 | 'upload_date': '20151231', | |
19 | 'timestamp': 1451564040, | |
20 | 'age_limit': 0, | |
21 | 'thumbnails': 'mincount:5', | |
ec85ded8 | 22 | 'thumbnail': r're:^https?://.*\.jpg$', |
98e68806 | 23 | 'ext': 'flv', |
e0317686 | 24 | }, |
98e68806 S |
25 | 'params': { |
26 | # rtmp download | |
27 | 'skip_download': True, | |
e0317686 | 28 | }, |
98e68806 S |
29 | }, { |
30 | 'url': 'http://mnet.interest.me/tv/vod/172790', | |
31 | 'only_matching': True, | |
32 | }, { | |
33 | 'url': 'http://www.mnet.com/tv/vod/vod_view.asp?clip_id=172790&tabMenu=', | |
34 | 'only_matching': True, | |
35 | }] | |
e0317686 KH |
36 | |
37 | def _real_extract(self, url): | |
38 | video_id = self._match_id(url) | |
98e68806 | 39 | |
f5ac68d8 RA |
40 | # TODO: extract rtmp formats |
41 | # no stype -> rtmp url | |
42 | # stype=H -> m3u8 url | |
43 | # stype=M -> mpd url | |
98e68806 | 44 | info = self._download_json( |
f5ac68d8 RA |
45 | 'http://content.api.mnet.com/player/vodConfig', |
46 | video_id, 'Downloading vod config JSON', query={ | |
47 | 'id': video_id, | |
48 | 'ctype': 'CLIP', | |
49 | 'stype': 'H', | |
50 | })['data']['info'] | |
e0317686 KH |
51 | |
52 | title = info['title'] | |
98e68806 | 53 | |
f5ac68d8 RA |
54 | cdn_data = self._download_json( |
55 | info['cdn'], video_id, 'Downloading vod cdn JSON')['data'][0] | |
56 | m3u8_url = cdn_data['url'] | |
57 | token = cdn_data.get('token') | |
58 | if token and token != '-': | |
59 | m3u8_url += '?' + token | |
60 | formats = self._extract_wowza_formats( | |
61 | m3u8_url, video_id, skip_protocols=['rtmp', 'rtsp', 'f4m']) | |
62 | self._sort_formats(formats) | |
98e68806 | 63 | |
e0317686 KH |
64 | description = info.get('ment') |
65 | duration = parse_duration(info.get('time')) | |
66 | timestamp = parse_iso8601(info.get('date'), delimiter=' ') | |
67 | age_limit = info.get('adult') | |
68 | if age_limit is not None: | |
69 | age_limit = 0 if age_limit == 'N' else 18 | |
98e68806 S |
70 | thumbnails = [{ |
71 | 'id': thumb_format, | |
72 | 'url': thumb['url'], | |
73 | 'width': int_or_none(thumb.get('width')), | |
74 | 'height': int_or_none(thumb.get('height')), | |
75 | } for thumb_format, thumb in info.get('cover', {}).items() if thumb.get('url')] | |
e0317686 KH |
76 | |
77 | return { | |
78 | 'id': video_id, | |
79 | 'title': title, | |
e0317686 KH |
80 | 'description': description, |
81 | 'duration': duration, | |
82 | 'timestamp': timestamp, | |
83 | 'age_limit': age_limit, | |
84 | 'thumbnails': thumbnails, | |
98e68806 | 85 | 'formats': formats, |
e0317686 | 86 | } |