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