[musicplayon] Fix extraction (closes #9222)
This commit is contained in:
parent
3014b0ae83
commit
b1cf58f48f
@ -1,10 +1,13 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import int_or_none
|
from ..compat import compat_urlparse
|
||||||
|
from ..utils import (
|
||||||
|
int_or_none,
|
||||||
|
js_to_json,
|
||||||
|
mimetype2ext,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MusicPlayOnIE(InfoExtractor):
|
class MusicPlayOnIE(InfoExtractor):
|
||||||
@ -12,6 +15,7 @@ class MusicPlayOnIE(InfoExtractor):
|
|||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://en.musicplayon.com/play?v=433377',
|
'url': 'http://en.musicplayon.com/play?v=433377',
|
||||||
|
'md5': '00cdcdea1726abdf500d1e7fd6dd59bb',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '433377',
|
'id': '433377',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
@ -20,15 +24,10 @@ class MusicPlayOnIE(InfoExtractor):
|
|||||||
'duration': 342,
|
'duration': 342,
|
||||||
'uploader': 'ultrafish',
|
'uploader': 'ultrafish',
|
||||||
},
|
},
|
||||||
'params': {
|
|
||||||
# m3u8 download
|
|
||||||
'skip_download': True,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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')
|
|
||||||
|
|
||||||
page = self._download_webpage(url, video_id)
|
page = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
@ -40,28 +39,14 @@ class MusicPlayOnIE(InfoExtractor):
|
|||||||
uploader = self._html_search_regex(
|
uploader = self._html_search_regex(
|
||||||
r'<div>by <a href="[^"]+" class="purple">([^<]+)</a></div>', page, 'uploader', fatal=False)
|
r'<div>by <a href="[^"]+" class="purple">([^<]+)</a></div>', page, 'uploader', fatal=False)
|
||||||
|
|
||||||
formats = [
|
sources = self._parse_json(
|
||||||
{
|
self._search_regex(r'setup\[\'_sources\'\]\s*=\s*([^;]+);', page, 'video sources'),
|
||||||
'url': 'http://media0-eu-nl.musicplayon.com/stream-mobile?id=%s&type=.mp4' % video_id,
|
video_id, transform_source=js_to_json)
|
||||||
'ext': 'mp4',
|
formats = [{
|
||||||
}
|
'url': compat_urlparse.urljoin(url, source['src']),
|
||||||
]
|
'ext': mimetype2ext(source.get('type')),
|
||||||
|
'format_note': source.get('data-res'),
|
||||||
manifest = self._download_webpage(
|
} for source in sources]
|
||||||
'http://en.musicplayon.com/manifest.m3u8?v=%s' % video_id, video_id, 'Downloading manifest')
|
|
||||||
|
|
||||||
for entry in manifest.split('#')[1:]:
|
|
||||||
if entry.startswith('EXT-X-STREAM-INF:'):
|
|
||||||
meta, url, _ = entry.split('\n')
|
|
||||||
params = dict(param.split('=') for param in meta.split(',')[1:])
|
|
||||||
formats.append({
|
|
||||||
'url': url,
|
|
||||||
'ext': 'mp4',
|
|
||||||
'tbr': int(params['BANDWIDTH']),
|
|
||||||
'width': int(params['RESOLUTION'].split('x')[1]),
|
|
||||||
'height': int(params['RESOLUTION'].split('x')[-1]),
|
|
||||||
'format_note': params['NAME'].replace('"', '').strip(),
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user