1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-22 16:44:32 +01:00

[muzu] Modernize

This commit is contained in:
Philipp Hagemeister 2014-11-26 12:50:37 +01:00
parent 5c40bba82f
commit 535a66ef66

View File

@ -1,64 +1,65 @@
import re from __future__ import unicode_literals
import json
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..compat import (
compat_urllib_parse, compat_urllib_parse,
determine_ext,
) )
class MuzuTVIE(InfoExtractor): class MuzuTVIE(InfoExtractor):
_VALID_URL = r'https?://www\.muzu\.tv/(.+?)/(.+?)/(?P<id>\d+)' _VALID_URL = r'https?://www\.muzu\.tv/(.+?)/(.+?)/(?P<id>\d+)'
IE_NAME = u'muzu.tv' IE_NAME = 'muzu.tv'
_TEST = { _TEST = {
u'url': u'http://www.muzu.tv/defected/marcashken-featuring-sos-cat-walk-original-mix-music-video/1981454/', 'url': 'http://www.muzu.tv/defected/marcashken-featuring-sos-cat-walk-original-mix-music-video/1981454/',
u'file': u'1981454.mp4', 'md5': '98f8b2c7bc50578d6a0364fff2bfb000',
u'md5': u'98f8b2c7bc50578d6a0364fff2bfb000', 'info_dict': {
u'info_dict': { 'id': '1981454',
u'title': u'Cat Walk (Original Mix)', 'ext': 'mp4',
u'description': u'md5:90e868994de201b2570e4e5854e19420', 'title': 'Cat Walk (Original Mix)',
u'uploader': u'MarcAshken featuring SOS', 'description': 'md5:90e868994de201b2570e4e5854e19420',
'uploader': 'MarcAshken featuring SOS',
}, },
} }
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) video_id = self._match_id(url)
video_id = mobj.group('id')
info_data = compat_urllib_parse.urlencode({'format': 'json', info_data = compat_urllib_parse.urlencode({
'url': url, 'format': 'json',
}) 'url': url,
video_info_page = self._download_webpage('http://www.muzu.tv/api/oembed/?%s' % info_data, })
video_id, u'Downloading video info') info = self._download_json(
info = json.loads(video_info_page) 'http://www.muzu.tv/api/oembed/?%s' % info_data,
video_id, 'Downloading video info')
player_info_page = self._download_webpage('http://player.muzu.tv/player/playerInit?ai=%s' % video_id, player_info = self._download_json(
video_id, u'Downloading player info') 'http://player.muzu.tv/player/playerInit?ai=%s' % video_id,
video_info = json.loads(player_info_page)['videos'][0] video_id, 'Downloading player info')
video_info = player_info['videos'][0]
for quality in ['1080', '720', '480', '360']: for quality in ['1080', '720', '480', '360']:
if video_info.get('v%s' % quality): if video_info.get('v%s' % quality):
break break
data = compat_urllib_parse.urlencode({'ai': video_id, data = compat_urllib_parse.urlencode({
# Even if each time you watch a video the hash changes, 'ai': video_id,
# it seems to work for different videos, and it will work # Even if each time you watch a video the hash changes,
# even if you use any non empty string as a hash # it seems to work for different videos, and it will work
'viewhash': 'VBNff6djeV4HV5TRPW5kOHub2k', # even if you use any non empty string as a hash
'device': 'web', 'viewhash': 'VBNff6djeV4HV5TRPW5kOHub2k',
'qv': quality, 'device': 'web',
}) 'qv': quality,
video_url_page = self._download_webpage('http://player.muzu.tv/player/requestVideo?%s' % data, })
video_id, u'Downloading video url') video_url_info = self._download_json(
video_url_info = json.loads(video_url_page) 'http://player.muzu.tv/player/requestVideo?%s' % data,
video_id, 'Downloading video url')
video_url = video_url_info['url'] video_url = video_url_info['url']
return {'id': video_id, return {
'title': info['title'], 'id': video_id,
'url': video_url, 'title': info['title'],
'ext': determine_ext(video_url), 'url': video_url,
'thumbnail': info['thumbnail_url'], 'thumbnail': info['thumbnail_url'],
'description': info['description'], 'description': info['description'],
'uploader': info['author_name'], 'uploader': info['author_name'],
} }