]>
Commit | Line | Data |
---|---|---|
dcdb292f | 1 | # coding: utf-8 |
91a76c40 S |
2 | from __future__ import unicode_literals |
3 | ||
91a76c40 | 4 | from .common import InfoExtractor |
b1cf58f4 YCH |
5 | from ..compat import compat_urlparse |
6 | from ..utils import ( | |
7 | int_or_none, | |
8 | js_to_json, | |
9 | mimetype2ext, | |
10 | ) | |
91a76c40 S |
11 | |
12 | ||
13 | class MusicPlayOnIE(InfoExtractor): | |
0f97fb4d | 14 | _VALID_URL = r'https?://(?:.+?\.)?musicplayon\.com/play(?:-touch)?\?(?:v|pl=\d+&play)=(?P<id>\d+)' |
91a76c40 | 15 | |
0f97fb4d | 16 | _TESTS = [{ |
91a76c40 | 17 | 'url': 'http://en.musicplayon.com/play?v=433377', |
b1cf58f4 | 18 | 'md5': '00cdcdea1726abdf500d1e7fd6dd59bb', |
91a76c40 S |
19 | 'info_dict': { |
20 | 'id': '433377', | |
21 | 'ext': 'mp4', | |
22 | 'title': 'Rick Ross - Interview On Chelsea Lately (2014)', | |
23 | 'description': 'Rick Ross Interview On Chelsea Lately', | |
24 | 'duration': 342, | |
25 | 'uploader': 'ultrafish', | |
26 | }, | |
0f97fb4d YCH |
27 | }, { |
28 | 'url': 'http://en.musicplayon.com/play?pl=102&play=442629', | |
29 | 'only_matching': True, | |
30 | }] | |
31 | ||
32 | _URL_TEMPLATE = 'http://en.musicplayon.com/play?v=%s' | |
91a76c40 S |
33 | |
34 | def _real_extract(self, url): | |
b1cf58f4 | 35 | video_id = self._match_id(url) |
0f97fb4d | 36 | url = self._URL_TEMPLATE % video_id |
91a76c40 S |
37 | |
38 | page = self._download_webpage(url, video_id) | |
39 | ||
40 | title = self._og_search_title(page) | |
41 | description = self._og_search_description(page) | |
42 | thumbnail = self._og_search_thumbnail(page) | |
43 | duration = self._html_search_meta('video:duration', page, 'duration', fatal=False) | |
44 | view_count = self._og_search_property('count', page, fatal=False) | |
45 | uploader = self._html_search_regex( | |
46 | r'<div>by <a href="[^"]+" class="purple">([^<]+)</a></div>', page, 'uploader', fatal=False) | |
47 | ||
b1cf58f4 YCH |
48 | sources = self._parse_json( |
49 | self._search_regex(r'setup\[\'_sources\'\]\s*=\s*([^;]+);', page, 'video sources'), | |
50 | video_id, transform_source=js_to_json) | |
51 | formats = [{ | |
52 | 'url': compat_urlparse.urljoin(url, source['src']), | |
53 | 'ext': mimetype2ext(source.get('type')), | |
54 | 'format_note': source.get('data-res'), | |
55 | } for source in sources] | |
91a76c40 S |
56 | |
57 | return { | |
58 | 'id': video_id, | |
59 | 'title': title, | |
60 | 'description': description, | |
61 | 'thumbnail': thumbnail, | |
62 | 'uploader': uploader, | |
63 | 'duration': int_or_none(duration), | |
64 | 'view_count': int_or_none(view_count), | |
65 | 'formats': formats, | |
5f6a1245 | 66 | } |