logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

mwave.py (3279B)


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