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.

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