mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-23 00:16:48 +00:00
[YandexMusic] Fix CAPTCHA check
* correct logic in _download_webpage() hook (yt-dlp/yt-dlp#4432) * improve error message.
This commit is contained in:
parent
10f38086d4
commit
38b3a0980c
@ -30,17 +30,20 @@ class YandexMusicBaseIE(InfoExtractor):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _raise_captcha():
|
def _raise_captcha():
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'YandexMusic has considered youtube-dl requests automated and '
|
'YandexMusic has considered youtube-dl requests automated '
|
||||||
'asks you to solve a CAPTCHA. You can either wait for some '
|
'and asks you to solve a CAPTCHA. You can wait for some time '
|
||||||
'time until unblocked and optionally use --sleep-interval '
|
'until unblocked and optionally use --sleep-interval in future; '
|
||||||
'in future or alternatively you can go to https://music.yandex.ru/ '
|
'otherwise solve the CAPTCHA at https://music.yandex.ru/, '
|
||||||
'solve CAPTCHA, then export cookies and pass cookie file to '
|
'then export cookies and pass the cookie file to youtube-dl '
|
||||||
'youtube-dl with --cookies',
|
'with --cookies.',
|
||||||
expected=True)
|
expected=True)
|
||||||
|
|
||||||
def _download_webpage_handle(self, *args, **kwargs):
|
def _download_webpage_handle(self, *args, **kwargs):
|
||||||
webpage = super(YandexMusicBaseIE, self)._download_webpage_handle(*args, **kwargs)
|
webpage = super(YandexMusicBaseIE, self)._download_webpage_handle(*args, **kwargs)
|
||||||
if 'Нам очень жаль, но запросы, поступившие с вашего IP-адреса, похожи на автоматические.' in webpage:
|
blocked_ip_msg = (
|
||||||
|
'Нам очень жаль, но запросы, поступившие с '
|
||||||
|
'вашего IP-адреса, похожи на автоматические.')
|
||||||
|
if blocked_ip_msg in (webpage or [''])[0]:
|
||||||
self._raise_captcha()
|
self._raise_captcha()
|
||||||
return webpage
|
return webpage
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user