Merge remote-tracking branch 'lenaten/karaoketv'
[youtube-dl] / youtube_dl / extractor / eighttracks.py
index 9df2141c3166be943c80718ddd5e40b4b2ee0b24..fb5dbbe2b0c7d9bd15b87426e446ce73f903a6eb 100644 (file)
@@ -4,11 +4,12 @@ from __future__ import unicode_literals
 import json
 import random
 import re
-import time
 
 from .common import InfoExtractor
 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
 
@@ -136,7 +136,7 @@ class EightTracksIE(InfoExtractor):
                         raise
                     else:
                         download_tries += 1
-                        time.sleep(avg_song_duration)
+                        self._sleep(avg_song_duration, playlist_id)
 
             api_data = json.loads(api_json)
             track_data = api_data['set']['track']