mwave.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..compat import compat_str
  4. from ..utils import (
  5. int_or_none,
  6. parse_duration,
  7. )
  8. class MwaveIE(InfoExtractor):
  9. _VALID_URL = r'https?://mwave\.interest\.me/mnettv/videodetail\.m\?searchVideoDetailVO\.clip_id=(?P<id>[0-9]+)'
  10. _TEST = {
  11. 'url': 'http://mwave.interest.me/mnettv/videodetail.m?searchVideoDetailVO.clip_id=168859',
  12. # md5 is unstable
  13. 'info_dict': {
  14. 'id': '168859',
  15. 'ext': 'flv',
  16. 'title': '[M COUNTDOWN] SISTAR - SHAKE IT',
  17. 'thumbnail': 're:^https?://.*\.jpg$',
  18. 'uploader': 'M COUNTDOWN',
  19. 'duration': 206,
  20. 'view_count': int,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. vod_info = self._download_json(
  26. 'http://mwave.interest.me/onair/vod_info.m?vodtype=CL&sectorid=&endinfo=Y&id=%s' % video_id,
  27. video_id, 'Download vod JSON')
  28. formats = []
  29. for num, cdn_info in enumerate(vod_info['cdn']):
  30. stream_url = cdn_info.get('url')
  31. if not stream_url:
  32. continue
  33. stream_name = cdn_info.get('name') or compat_str(num)
  34. f4m_stream = self._download_json(
  35. stream_url, video_id,
  36. 'Download %s stream JSON' % stream_name)
  37. f4m_url = f4m_stream.get('fileurl')
  38. if not f4m_url:
  39. continue
  40. formats.extend(
  41. self._extract_f4m_formats(f4m_url + '&hdcore=3.0.3', video_id, f4m_id=stream_name))
  42. self._sort_formats(formats)
  43. return {
  44. 'id': video_id,
  45. 'title': vod_info['title'],
  46. 'thumbnail': vod_info.get('cover'),
  47. 'uploader': vod_info.get('program_title'),
  48. 'duration': parse_duration(vod_info.get('time')),
  49. 'view_count': int_or_none(vod_info.get('hit')),
  50. 'formats': formats,
  51. }
  52. class MwaveMeetGreetIE(InfoExtractor):
  53. _VALID_URL = r'https?://mwave\.interest\.me/meetgreet/view/(?P<id>[0-9]+)'
  54. _TEST = {
  55. 'url': 'http://mwave.interest.me/meetgreet/view/256',
  56. 'info_dict': {
  57. 'id': '173294',
  58. 'ext': 'flv',
  59. 'title': '[MEET&GREET] Park BoRam',
  60. 'thumbnail': 're:^https?://.*\.jpg$',
  61. 'uploader': 'Mwave',
  62. 'duration': 3634,
  63. 'view_count': int,
  64. }
  65. }
  66. def _real_extract(self, url):
  67. video_id = self._match_id(url)
  68. webpage = self._download_webpage(url, video_id)
  69. clip_id = self._html_search_regex(r'<iframe src="/mnettv/ifr_clip\.m\?searchVideoDetailVO\.clip_id=(?P<id>[0-9]+)', webpage, 'clip ID')
  70. clip_url = 'http://mwave.interest.me/mnettv/videodetail.m?searchVideoDetailVO.clip_id={0}'.format(clip_id)
  71. return self.url_result(clip_url, 'Mwave', clip_id)