]>
Commit | Line | Data |
---|---|---|
1cdedfee | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
be64b5b0 PH |
5 | from ..compat import ( |
6 | compat_chr, | |
7 | compat_ord, | |
8 | ) | |
9 | from ..utils import ( | |
10 | int_or_none, | |
11 | parse_filesize, | |
12 | ) | |
1cdedfee | 13 | |
14 | ||
15 | class XMinusIE(InfoExtractor): | |
16 | _VALID_URL = r'https?://(?:www\.)?x-minus\.org/track/(?P<id>[0-9]+)' | |
17 | _TEST = { | |
18 | 'url': 'http://x-minus.org/track/4542/%D0%BF%D0%B5%D1%81%D0%B5%D0%BD%D0%BA%D0%B0-%D1%88%D0%BE%D1%84%D0%B5%D1%80%D0%B0.html', | |
19 | 'md5': '401a15f2d2dcf6d592cb95528d72a2a8', | |
20 | 'info_dict': { | |
21 | 'id': '4542', | |
22 | 'ext': 'mp3', | |
23 | 'title': 'Леонид Агутин-Песенка шофера', | |
24 | 'duration': 156, | |
be64b5b0 PH |
25 | 'tbr': 320, |
26 | 'filesize_approx': 5900000, | |
27 | 'view_count': int, | |
1cdedfee | 28 | } |
29 | } | |
30 | ||
31 | def _real_extract(self, url): | |
32 | video_id = self._match_id(url) | |
1cdedfee | 33 | webpage = self._download_webpage(url, video_id) |
be64b5b0 | 34 | |
1cdedfee | 35 | artist = self._html_search_regex( |
be64b5b0 | 36 | r'minus_track\.artist="(.+?)"', webpage, 'artist') |
1cdedfee | 37 | title = artist + '-' + self._html_search_regex( |
be64b5b0 | 38 | r'minus_track\.title="(.+?)"', webpage, 'title') |
1cdedfee | 39 | duration = int_or_none(self._html_search_regex( |
be64b5b0 PH |
40 | r'minus_track\.dur_sec=\'([0-9]*?)\'', |
41 | webpage, 'duration', fatal=False)) | |
42 | filesize_approx = parse_filesize(self._html_search_regex( | |
43 | r'<div class="filesize[^"]*"></div>\s*([0-9.]+\s*[a-zA-Z][bB])', | |
44 | webpage, 'approximate filesize', fatal=False)) | |
45 | tbr = int_or_none(self._html_search_regex( | |
46 | r'<div class="quality[^"]*"></div>\s*([0-9]+)\s*kbps', | |
47 | webpage, 'bitrate', fatal=False)) | |
48 | view_count = int_or_none(self._html_search_regex( | |
49 | r'<div class="quality.*?► ([0-9]+)', | |
50 | webpage, 'view count', fatal=False)) | |
51 | ||
1cdedfee | 52 | enc_token = self._html_search_regex( |
313d4572 | 53 | r'minus_track\.tkn="(.+?)"', webpage, 'enc_token') |
be64b5b0 PH |
54 | token = ''.join( |
55 | c if pos == 3 else compat_chr(compat_ord(c) - 1) | |
56 | for pos, c in enumerate(reversed(enc_token))) | |
57 | video_url = 'http://x-minus.org/dwlf/%s/%s.mp3' % (video_id, token) | |
1cdedfee | 58 | |
59 | return { | |
60 | 'id': video_id, | |
61 | 'title': title, | |
be64b5b0 | 62 | 'url': video_url, |
1cdedfee | 63 | 'duration': duration, |
be64b5b0 PH |
64 | 'filesize_approx': filesize_approx, |
65 | 'tbr': tbr, | |
66 | 'view_count': view_count, | |
1cdedfee | 67 | } |