X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fthesixtyone.py;h=d8b1fd2813eadc3d17a17a6d46766b3c9c4ea37a;hb=611c1dd96efc36a788475e14cc4de64d554d28a0;hp=a77c6a2fc9f2838305145c97e9920d09635ceba7;hpb=c24dfef63c55ef1a5424d11b485c3b76245448a4;p=youtube-dl diff --git a/youtube_dl/extractor/thesixtyone.py b/youtube_dl/extractor/thesixtyone.py index a77c6a2fc..d8b1fd281 100644 --- a/youtube_dl/extractor/thesixtyone.py +++ b/youtube_dl/extractor/thesixtyone.py @@ -1,9 +1,6 @@ # coding: utf-8 from __future__ import unicode_literals -import json -import re - from .common import InfoExtractor from ..utils import unified_strdate @@ -17,7 +14,7 @@ class TheSixtyOneIE(InfoExtractor): song )/(?P[A-Za-z0-9]+)/?$''' _SONG_URL_TEMPLATE = 'http://thesixtyone.com/s/{0:}' - _SONG_FILE_URL_TEMPLATE = 'http://{audio_server:}.thesixtyone.com/thesixtyone_production/audio/{0:}_stream' + _SONG_FILE_URL_TEMPLATE = 'http://{audio_server:}/thesixtyone_production/audio/{0:}_stream' _THUMBNAIL_URL_TEMPLATE = '{photo_base_url:}_desktop' _TESTS = [ { @@ -51,33 +48,38 @@ class TheSixtyOneIE(InfoExtractor): ] _DECODE_MAP = { - "x": "a", - "m": "b", - "w": "c", - "q": "d", - "n": "e", - "p": "f", - "a": "0", - "h": "1", - "e": "2", - "u": "3", - "s": "4", - "i": "5", - "o": "6", - "y": "7", - "r": "8", - "c": "9" + 'x': 'a', + 'm': 'b', + 'w': 'c', + 'q': 'd', + 'n': 'e', + 'p': 'f', + 'a': '0', + 'h': '1', + 'e': '2', + 'u': '3', + 's': '4', + 'i': '5', + 'o': '6', + 'y': '7', + 'r': '8', + 'c': '9' } def _real_extract(self, url): - mobj = re.match(self._VALID_URL, url) - song_id = mobj.group('id') + song_id = self._match_id(url) webpage = self._download_webpage( self._SONG_URL_TEMPLATE.format(song_id), song_id) - song_data = json.loads(self._search_regex( - r'"%s":\s(\{.*?\})' % song_id, webpage, 'song_data')) + song_data = self._parse_json(self._search_regex( + r'"%s":\s(\{.*?\})' % song_id, webpage, 'song_data'), song_id) + + if self._search_regex(r'(t61\.s3_audio_load\s*=\s*1\.0;)', webpage, 's3_audio_load marker', default=None): + song_data['audio_server'] = 's3.amazonaws.com' + else: + song_data['audio_server'] = song_data['audio_server'] + '.thesixtyone.com' + keys = [self._DECODE_MAP.get(s, s) for s in song_data['key']] url = self._SONG_FILE_URL_TEMPLATE.format( "".join(reversed(keys)), **song_data)