1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-05 00:51:29 +00:00

[eighttracks] Improve waiting (#3954)

This commit is contained in:
Philipp Hagemeister 2015-01-10 05:51:07 +01:00
parent c24dfef63c
commit f71fdb0acc

View file

@ -4,11 +4,12 @@ from __future__ import unicode_literals
import json import json
import random import random
import re import re
import time
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import ( from ..compat import (
compat_str, compat_str,
)
from ..utils import (
ExtractorError, ExtractorError,
) )
@ -115,7 +116,7 @@ class EightTracksIE(InfoExtractor):
mix_id = data['id'] mix_id = data['id']
track_count = data['tracks_count'] track_count = data['tracks_count']
duration = data['duration'] 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) first_url = 'http://8tracks.com/sets/%s/play?player=sm&mix_id=%s&format=jsonh' % (session, mix_id)
next_url = first_url next_url = first_url
entries = [] entries = []
@ -136,7 +137,7 @@ class EightTracksIE(InfoExtractor):
raise raise
else: else:
download_tries += 1 download_tries += 1
time.sleep(avg_song_duration) self._sleep(avg_song_duration, playlist_id)
api_data = json.loads(api_json) api_data = json.loads(api_json)
track_data = api_data['set']['track'] track_data = api_data['set']['track']