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.

64 lines
2.8 KiB

  1. import re
  2. import json
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urllib_parse,
  6. determine_ext,
  7. )
  8. class MuzuTVIE(InfoExtractor):
  9. _VALID_URL = r'https?://www.muzu.tv/(.+?)/(.+?)/(?P<id>\d+)'
  10. IE_NAME = u'muzu.tv'
  11. _TEST = {
  12. u'url': u'http://www.muzu.tv/defected/marcashken-featuring-sos-cat-walk-original-mix-music-video/1981454/',
  13. u'file': u'1981454.mp4',
  14. u'md5': u'98f8b2c7bc50578d6a0364fff2bfb000',
  15. u'info_dict': {
  16. u'title': u'Cat Walk (Original Mix)',
  17. u'description': u'md5:90e868994de201b2570e4e5854e19420',
  18. u'uploader': u'MarcAshken featuring SOS',
  19. },
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group('id')
  24. info_data = compat_urllib_parse.urlencode({'format': 'json',
  25. 'url': url,
  26. })
  27. video_info_page = self._download_webpage('http://www.muzu.tv/api/oembed/?%s' % info_data,
  28. video_id, u'Downloading video info')
  29. info = json.loads(video_info_page)
  30. player_info_page = self._download_webpage('http://player.muzu.tv/player/playerInit?ai=%s' % video_id,
  31. video_id, u'Downloading player info')
  32. video_info = json.loads(player_info_page)['videos'][0]
  33. for quality in ['1080' , '720', '480', '360']:
  34. if video_info.get('v%s' % quality):
  35. break
  36. data = compat_urllib_parse.urlencode({'ai': video_id,
  37. # Even if each time you watch a video the hash changes,
  38. # it seems to work for different videos, and it will work
  39. # even if you use any non empty string as a hash
  40. 'viewhash': 'VBNff6djeV4HV5TRPW5kOHub2k',
  41. 'device': 'web',
  42. 'qv': quality,
  43. })
  44. video_url_page = self._download_webpage('http://player.muzu.tv/player/requestVideo?%s' % data,
  45. video_id, u'Downloading video url')
  46. video_url_info = json.loads(video_url_page)
  47. video_url = video_url_info['url']
  48. return {'id': video_id,
  49. 'title': info['title'],
  50. 'url': video_url,
  51. 'ext': determine_ext(video_url),
  52. 'thumbnail': info['thumbnail_url'],
  53. 'description': info['description'],
  54. 'uploader': info['author_name'],
  55. }