mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-23 04:30:10 +09: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
620298e0ff
commit
94f181f9f5
@ -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