]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/mwave.py
Merge branch 'mwave-meetgreet' of https://github.com/pmrowla/youtube-dl into pmrowla...
[yt-dlp.git] / 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 is unstable
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 }
59
60
61 class MwaveMeetGreetIE(InfoExtractor):
62 _VALID_URL = r'https?://mwave\.interest\.me/meetgreet/view/(?P<id>[0-9]+)'
63 _TEST = {
64 'url': 'http://mwave.interest.me/meetgreet/view/256',
65 'info_dict': {
66 'id': '173294',
67 'ext': 'flv',
68 'title': '[MEET&GREET] Park BoRam',
69 'thumbnail': 're:^https?://.*\.jpg$',
70 'uploader': 'Mwave',
71 'duration': 3634,
72 'view_count': int,
73 }
74 }
75
76 def _real_extract(self, url):
77 video_id = self._match_id(url)
78 webpage = self._download_webpage(url, video_id)
79 clip_id = self._html_search_regex(r'<iframe src="/mnettv/ifr_clip\.m\?searchVideoDetailVO\.clip_id=(?P<id>[0-9]+)', webpage, 'clip ID')
80 clip_url = 'http://mwave.interest.me/mnettv/videodetail.m?searchVideoDetailVO.clip_id={0}'.format(clip_id)
81 return self.url_result(clip_url, 'Mwave', clip_id)