]> jfr.im git - yt-dlp.git/blame - 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
CommitLineData
7900aede 1from __future__ import unicode_literals
2
3from .common import InfoExtractor
22c83245
S
4from ..compat import compat_str
5from ..utils import (
6 int_or_none,
7 parse_duration,
8)
7900aede 9
10
11class MwaveIE(InfoExtractor):
7900aede 12 _VALID_URL = r'https?://mwave\.interest\.me/mnettv/videodetail\.m\?searchVideoDetailVO\.clip_id=(?P<id>[0-9]+)'
22c83245 13 _TEST = {
7900aede 14 'url': 'http://mwave.interest.me/mnettv/videodetail.m?searchVideoDetailVO.clip_id=168859',
a8062eab 15 # md5 is unstable
7900aede 16 'info_dict': {
17 'id': '168859',
18 'ext': 'flv',
19 'title': '[M COUNTDOWN] SISTAR - SHAKE IT',
22c83245
S
20 'thumbnail': 're:^https?://.*\.jpg$',
21 'uploader': 'M COUNTDOWN',
22 'duration': 206,
23 'view_count': int,
7900aede 24 }
22c83245 25 }
7900aede 26
27 def _real_extract(self, url):
28 video_id = self._match_id(url)
29
22c83245 30 vod_info = self._download_json(
7900aede 31 'http://mwave.interest.me/onair/vod_info.m?vodtype=CL&sectorid=&endinfo=Y&id=%s' % video_id,
22c83245 32 video_id, 'Download vod JSON')
7900aede 33
34 formats = []
22c83245
S
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
7900aede 46 formats.extend(
22c83245 47 self._extract_f4m_formats(f4m_url + '&hdcore=3.0.3', video_id, f4m_id=stream_name))
7900aede 48 self._sort_formats(formats)
49
50 return {
51 'id': video_id,
22c83245
S
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')),
7900aede 57 'formats': formats,
58 }
5b5d7cc1
PR
59
60
61class 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)