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.

74 lines
2.6 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import int_or_none
  6. class MusicPlayOnIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:.+?\.)?musicplayon\.com/play(?:-touch)?\?(?:v|pl=100&play)=(?P<id>\d+)'
  8. _TEST = {
  9. 'url': 'http://en.musicplayon.com/play?v=433377',
  10. 'info_dict': {
  11. 'id': '433377',
  12. 'ext': 'mp4',
  13. 'title': 'Rick Ross - Interview On Chelsea Lately (2014)',
  14. 'description': 'Rick Ross Interview On Chelsea Lately',
  15. 'duration': 342,
  16. 'uploader': 'ultrafish',
  17. },
  18. 'params': {
  19. # m3u8 download
  20. 'skip_download': True,
  21. },
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. page = self._download_webpage(url, video_id)
  27. title = self._og_search_title(page)
  28. description = self._og_search_description(page)
  29. thumbnail = self._og_search_thumbnail(page)
  30. duration = self._html_search_meta('video:duration', page, 'duration', fatal=False)
  31. view_count = self._og_search_property('count', page, fatal=False)
  32. uploader = self._html_search_regex(
  33. r'<div>by&nbsp;<a href="[^"]+" class="purple">([^<]+)</a></div>', page, 'uploader', fatal=False)
  34. formats = [
  35. {
  36. 'url': 'http://media0-eu-nl.musicplayon.com/stream-mobile?id=%s&type=.mp4' % video_id,
  37. 'ext': 'mp4',
  38. }
  39. ]
  40. manifest = self._download_webpage(
  41. 'http://en.musicplayon.com/manifest.m3u8?v=%s' % video_id, video_id, 'Downloading manifest')
  42. for entry in manifest.split('#')[1:]:
  43. if entry.startswith('EXT-X-STREAM-INF:'):
  44. meta, url, _ = entry.split('\n')
  45. params = dict(param.split('=') for param in meta.split(',')[1:])
  46. formats.append({
  47. 'url': url,
  48. 'ext': 'mp4',
  49. 'tbr': int(params['BANDWIDTH']),
  50. 'width': int(params['RESOLUTION'].split('x')[1]),
  51. 'height': int(params['RESOLUTION'].split('x')[-1]),
  52. 'format_note': params['NAME'].replace('"', '').strip(),
  53. })
  54. return {
  55. 'id': video_id,
  56. 'title': title,
  57. 'description': description,
  58. 'thumbnail': thumbnail,
  59. 'uploader': uploader,
  60. 'duration': int_or_none(duration),
  61. 'view_count': int_or_none(view_count),
  62. 'formats': formats,
  63. }