]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mnet.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  12 class MnetIE(InfoExtractor
): 
  13     _VALID_URL 
= r
'https?://(?:www\.)?mnet\.(?:com|interest\.me)/tv/vod/(?:.*?\bclip_id=)?(?P<id>[0-9]+)' 
  15         'url': 'http://www.mnet.com/tv/vod/171008', 
  18             'title': 'SS_이해인@히든박스', 
  19             'description': 'md5:b9efa592c3918b615ba69fe9f8a05c55', 
  21             'upload_date': '20151231', 
  22             'timestamp': 1451564040, 
  24             'thumbnails': 'mincount:5', 
  25             'thumbnail': r
're:^https?://.*\.jpg$', 
  30             'skip_download': True, 
  33         'url': 'http://mnet.interest.me/tv/vod/172790', 
  34         'only_matching': True, 
  36         'url': 'http://www.mnet.com/tv/vod/vod_view.asp?clip_id=172790&tabMenu=', 
  37         'only_matching': True, 
  40     def _real_extract(self
, url
): 
  41         video_id 
= self
._match
_id
(url
) 
  43         # TODO: extract rtmp formats 
  44         # no stype -> rtmp url 
  47         info 
= self
._download
_json
( 
  48             'http://content.api.mnet.com/player/vodConfig', 
  49             video_id
, 'Downloading vod config JSON', query
={ 
  57         cdn_data 
= self
._download
_json
( 
  58             info
['cdn'], video_id
, 'Downloading vod cdn JSON')['data'][0] 
  59         m3u8_url 
= cdn_data
['url'] 
  60         token 
= cdn_data
.get('token') 
  61         if token 
and token 
!= '-': 
  62             m3u8_url 
+= '?' + token
 
  63         formats 
= self
._extract
_wowza
_formats
( 
  64             m3u8_url
, video_id
, skip_protocols
=['rtmp', 'rtsp', 'f4m']) 
  65         self
._sort
_formats
(formats
) 
  67         description 
= info
.get('ment') 
  68         duration 
= parse_duration(info
.get('time')) 
  69         timestamp 
= parse_iso8601(info
.get('date'), delimiter
=' ') 
  70         age_limit 
= info
.get('adult') 
  71         if age_limit 
is not None: 
  72             age_limit 
= 0 if age_limit 
== 'N' else 18 
  76             'width': int_or_none(thumb
.get('width')), 
  77             'height': int_or_none(thumb
.get('height')), 
  78         } for thumb_format
, thumb 
in info
.get('cover', {}).items() if thumb
.get('url')] 
  83             'description': description
, 
  85             'timestamp': timestamp
, 
  86             'age_limit': age_limit
, 
  87             'thumbnails': thumbnails
,