X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Feighttracks.py;h=fb5dbbe2b0c7d9bd15b87426e446ce73f903a6eb;hb=314368c822428437e60bbc24af65d5415717632c;hp=101a096999b6b2b7c65104b2c1b245c7d233bc2f;hpb=7b61ac3ddf0bfe660266e70fc7c10f048758698f;p=youtube-dl.git diff --git a/youtube_dl/extractor/eighttracks.py b/youtube_dl/extractor/eighttracks.py index 101a09699..fb5dbbe2b 100644 --- a/youtube_dl/extractor/eighttracks.py +++ b/youtube_dl/extractor/eighttracks.py @@ -4,11 +4,12 @@ from __future__ import unicode_literals import json import random import re -import time from .common import InfoExtractor -from ..utils import ( +from ..compat import ( compat_str, +) +from ..utils import ( ExtractorError, ) @@ -115,13 +116,12 @@ class EightTracksIE(InfoExtractor): mix_id = data['id'] track_count = data['tracks_count'] duration = data['duration'] - avg_song_duration = duration / track_count + avg_song_duration = float(duration) / track_count first_url = 'http://8tracks.com/sets/%s/play?player=sm&mix_id=%s&format=jsonh' % (session, mix_id) next_url = first_url entries = [] for i in range(track_count): - api_json = None download_tries = 0 @@ -135,15 +135,15 @@ class EightTracksIE(InfoExtractor): if download_tries > 3: raise else: - ++download_tries - time.sleep(avg_song_duration) + download_tries += 1 + self._sleep(avg_song_duration, playlist_id) api_data = json.loads(api_json) track_data = api_data['set']['track'] info = { 'id': compat_str(track_data['id']), 'url': track_data['track_file_stream_url'], - 'title': track_data['performer'] + u' - ' + track_data['name'], + 'title': track_data['performer'] + ' - ' + track_data['name'], 'raw_title': track_data['name'], 'uploader_id': data['user']['login'], 'ext': 'm4a',