]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mnet.py
debian/control: Add B-D on pandoc and zip. Closes: #828905.
[youtubedl] / youtube_dl / extractor / mnet.py
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 'url': 'http://www.mnet.com/tv/vod/171008',
16 'info_dict': {
17 'id': '171008',
18 'title': 'SS_이해인@히든박스',
19 'description': 'md5:b9efa592c3918b615ba69fe9f8a05c55',
20 'duration': 88,
21 'upload_date': '20151231',
22 'timestamp': 1451564040,
23 'age_limit': 0,
24 'thumbnails': 'mincount:5',
25 'thumbnail': 're:^https?://.*\.jpg$',
26 'ext': 'flv',
27 },
28 'params': {
29 # rtmp download
30 'skip_download': True,
31 },
32 }, {
33 'url': 'http://mnet.interest.me/tv/vod/172790',
34 'only_matching': True,
35 }, {
36 'url': 'http://www.mnet.com/tv/vod/vod_view.asp?clip_id=172790&tabMenu=',
37 'only_matching': True,
38 }]
39
40 def _real_extract(self, url):
41 video_id = self._match_id(url)
42
43 info = self._download_json(
44 'http://content.api.mnet.com/player/vodConfig?id=%s&ctype=CLIP' % video_id,
45 video_id, 'Downloading vod config JSON')['data']['info']
46
47 title = info['title']
48
49 rtmp_info = self._download_json(
50 info['cdn'], video_id, 'Downloading vod cdn JSON')
51
52 formats = [{
53 'url': rtmp_info['serverurl'] + rtmp_info['fileurl'],
54 'ext': 'flv',
55 'page_url': url,
56 'player_url': 'http://flvfile.mnet.com/service/player/201602/cjem_player_tv.swf?v=201602191318',
57 }]
58
59 description = info.get('ment')
60 duration = parse_duration(info.get('time'))
61 timestamp = parse_iso8601(info.get('date'), delimiter=' ')
62 age_limit = info.get('adult')
63 if age_limit is not None:
64 age_limit = 0 if age_limit == 'N' else 18
65 thumbnails = [{
66 'id': thumb_format,
67 'url': thumb['url'],
68 'width': int_or_none(thumb.get('width')),
69 'height': int_or_none(thumb.get('height')),
70 } for thumb_format, thumb in info.get('cover', {}).items() if thumb.get('url')]
71
72 return {
73 'id': video_id,
74 'title': title,
75 'description': description,
76 'duration': duration,
77 'timestamp': timestamp,
78 'age_limit': age_limit,
79 'thumbnails': thumbnails,
80 'formats': formats,
81 }