]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/muzu.py
[youtube] Extract start_time
[yt-dlp.git] / youtube_dl / extractor / muzu.py
CommitLineData
535a66ef 1from __future__ import unicode_literals
577664c8
JMF
2
3from .common import InfoExtractor
535a66ef 4from ..compat import (
577664c8 5 compat_urllib_parse,
577664c8
JMF
6)
7
8
9class MuzuTVIE(InfoExtractor):
c0ade33e 10 _VALID_URL = r'https?://www\.muzu\.tv/(.+?)/(.+?)/(?P<id>\d+)'
535a66ef 11 IE_NAME = 'muzu.tv'
577664c8
JMF
12
13 _TEST = {
535a66ef
PH
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',
577664c8
JMF
22 },
23 }
24
25 def _real_extract(self, url):
535a66ef 26 video_id = self._match_id(url)
577664c8 27
535a66ef
PH
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')
577664c8 35
535a66ef
PH
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]
5f6a1245 40 for quality in ['1080', '720', '480', '360']:
577664c8
JMF
41 if video_info.get('v%s' % quality):
42 break
43
535a66ef
PH
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')
577664c8
JMF
56 video_url = video_url_info['url']
57
535a66ef
PH
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 }