[soundcloud] Always add streaming formats

This commit is contained in:
Philipp Hagemeister 2014-03-24 02:21:17 +01:00
parent 83622b6d2f
commit 5e114e4bfe
1 changed files with 30 additions and 29 deletions

View File

@ -124,18 +124,20 @@ class SoundcloudIE(InfoExtractor):
'description': info['description'], 'description': info['description'],
'thumbnail': thumbnail, 'thumbnail': thumbnail,
} }
formats = []
if info.get('downloadable', False): if info.get('downloadable', False):
# We can build a direct link to the song # We can build a direct link to the song
format_url = ( format_url = (
'https://api.soundcloud.com/tracks/{0}/download?client_id={1}'.format( 'https://api.soundcloud.com/tracks/{0}/download?client_id={1}'.format(
track_id, self._CLIENT_ID)) track_id, self._CLIENT_ID))
result['formats'] = [{ formats.append({
'format_id': 'download', 'format_id': 'download',
'ext': info.get('original_format', 'mp3'), 'ext': info.get('original_format', 'mp3'),
'url': format_url, 'url': format_url,
'vcodec': 'none', 'vcodec': 'none',
}] 'preference': 10,
else: })
# We have to retrieve the url # We have to retrieve the url
streams_url = ('http://api.soundcloud.com/i1/tracks/{0}/streams?' streams_url = ('http://api.soundcloud.com/i1/tracks/{0}/streams?'
'client_id={1}&secret_token={2}'.format(track_id, self._IPHONE_CLIENT_ID, secret_token)) 'client_id={1}&secret_token={2}'.format(track_id, self._IPHONE_CLIENT_ID, secret_token))
@ -143,7 +145,6 @@ class SoundcloudIE(InfoExtractor):
streams_url, streams_url,
track_id, 'Downloading track url') track_id, 'Downloading track url')
formats = []
format_dict = json.loads(stream_json) format_dict = json.loads(stream_json)
for key, stream_url in format_dict.items(): for key, stream_url in format_dict.items():
if key.startswith('http'): if key.startswith('http'):