mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-22 07:56:49 +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
|
||||
def _raise_captcha():
|
||||
raise ExtractorError(
|
||||
'YandexMusic has considered youtube-dl requests automated and '
|
||||
'asks you to solve a CAPTCHA. You can either wait for some '
|
||||
'time until unblocked and optionally use --sleep-interval '
|
||||
'in future or alternatively you can go to https://music.yandex.ru/ '
|
||||
'solve CAPTCHA, then export cookies and pass cookie file to '
|
||||
'youtube-dl with --cookies',
|
||||
'YandexMusic has considered youtube-dl requests automated '
|
||||
'and asks you to solve a CAPTCHA. You can wait for some time '
|
||||
'until unblocked and optionally use --sleep-interval in future; '
|
||||
'otherwise solve the CAPTCHA at https://music.yandex.ru/, '
|
||||
'then export cookies and pass the cookie file to youtube-dl '
|
||||
'with --cookies.',
|
||||
expected=True)
|
||||
|
||||
def _download_webpage_handle(self, *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()
|
||||
return webpage
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user