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.

65 lines
2.2 KiB

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