2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..utils import int_or_none
8 class XMinusIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?x-minus\.org/track/(?P<id>[0-9]+)'
11 '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',
12 'md5': '401a15f2d2dcf6d592cb95528d72a2a8',
16 'title': 'Леонид Агутин-Песенка шофера',
21 def _real_extract(self, url):
22 video_id = self._match_id(url)
24 # TODO more code goes here, for example ...
25 webpage = self._download_webpage(url, video_id)
26 artist = self._html_search_regex(
27 r'minus_track.artist="(.+?)"', webpage, 'artist')
28 title = artist + '-' + self._html_search_regex(
29 r'minus_track.title="(.+?)"', webpage, 'title')
30 duration = int_or_none(self._html_search_regex(
31 r'minus_track.dur_sec=\'([0-9]+?)\'', webpage, 'duration'))
32 enc_token = self._html_search_regex(
33 r'data-mt="(.*?)"', webpage, 'enc_token')
34 token = self._decode_token(enc_token)
35 url = 'http://x-minus.org/dwlf/{}/{}.mp3'.format(video_id, token)
44 def _decode_token(self, enc_token):
47 for c in reversed(enc_token):
49 token += chr(ord(c) - 1)