]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/mwave.py
[brightcove] Fix _extract_urls
[youtube-dl] / youtube_dl / extractor / mwave.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..compat import compat_str
5 from ..utils import (
6     int_or_none,
7     parse_duration,
8 )
9
10
11 class MwaveIE(InfoExtractor):
12     _VALID_URL = r'https?://mwave\.interest\.me/mnettv/videodetail\.m\?searchVideoDetailVO\.clip_id=(?P<id>[0-9]+)'
13     _TEST = {
14         'url': 'http://mwave.interest.me/mnettv/videodetail.m?searchVideoDetailVO.clip_id=168859',
15         'md5': 'c930e27b7720aaa3c9d0018dfc8ff6cc',
16         'info_dict': {
17             'id': '168859',
18             'ext': 'flv',
19             'title': '[M COUNTDOWN] SISTAR - SHAKE IT',
20             'thumbnail': 're:^https?://.*\.jpg$',
21             'uploader': 'M COUNTDOWN',
22             'duration': 206,
23             'view_count': int,
24         }
25     }
26
27     def _real_extract(self, url):
28         video_id = self._match_id(url)
29
30         vod_info = self._download_json(
31             'http://mwave.interest.me/onair/vod_info.m?vodtype=CL&sectorid=&endinfo=Y&id=%s' % video_id,
32             video_id, 'Download vod JSON')
33
34         formats = []
35         for num, cdn_info in enumerate(vod_info['cdn']):
36             stream_url = cdn_info.get('url')
37             if not stream_url:
38                 continue
39             stream_name = cdn_info.get('name') or compat_str(num)
40             f4m_stream = self._download_json(
41                 stream_url, video_id,
42                 'Download %s stream JSON' % stream_name)
43             f4m_url = f4m_stream.get('fileurl')
44             if not f4m_url:
45                 continue
46             formats.extend(
47                 self._extract_f4m_formats(f4m_url + '&hdcore=3.0.3', video_id, f4m_id=stream_name))
48         self._sort_formats(formats)
49
50         return {
51             'id': video_id,
52             'title': vod_info['title'],
53             'thumbnail': vod_info.get('cover'),
54             'uploader': vod_info.get('program_title'),
55             'duration': parse_duration(vod_info.get('time')),
56             'view_count': int_or_none(vod_info.get('hit')),
57             'formats': formats,
58         }