You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.9 KiB

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