From 38eb2968abce9078f28904046b8e26b0d87ada61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Sun, 22 Nov 2015 00:07:09 +0600 Subject: [PATCH] [pluralsight] Clarify and randomize ViewClip sleep interval --- youtube_dl/extractor/pluralsight.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/pluralsight.py b/youtube_dl/extractor/pluralsight.py index d542a9e0e..8481a10b0 100644 --- a/youtube_dl/extractor/pluralsight.py +++ b/youtube_dl/extractor/pluralsight.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals import json +import random from .common import InfoExtractor from ..compat import ( @@ -156,9 +157,17 @@ def _real_extract(self, url): format_id = '%s-%s' % (ext, quality) clip_url = self._download_webpage( request, display_id, 'Downloading %s URL' % format_id, fatal=False) - # #6989: sleep 3 seconds to avoid 429 errors. - # should help with #6842. - self._sleep(3, display_id) + + # Pluralsight tracks multiple sequential calls to ViewClip API and start + # to return 429 HTTP errors after some time (see + # https://github.com/rg3/youtube-dl/pull/6989). Moreover it may even lead + # to account ban (see https://github.com/rg3/youtube-dl/issues/6842). + # To somewhat reduce the probability of these consequences + # we will sleep random amount of time before each call to ViewClip. + self._sleep( + random.randint(2, 5), display_id, + '%(video_id)s: Waiting for %(timeout)s seconds to avoid throttling') + if not clip_url: continue f.update({