From 49f523ca506f3b57e8a54b97c6a29dc71624aeef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sergey=20M=E2=80=A4?= Date: Mon, 11 Apr 2016 20:45:58 +0600 Subject: [PATCH] [mixcloud] Capture error message (#9156) --- youtube_dl/extractor/mixcloud.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/mixcloud.py b/youtube_dl/extractor/mixcloud.py index 101497118..9638cc9e6 100644 --- a/youtube_dl/extractor/mixcloud.py +++ b/youtube_dl/extractor/mixcloud.py @@ -7,6 +7,7 @@ from ..compat import compat_urllib_parse_unquote from ..utils import ( ExtractorError, HEADRequest, + NO_DEFAULT, parse_count, str_to_int, ) @@ -63,8 +64,17 @@ class MixcloudIE(InfoExtractor): webpage = self._download_webpage(url, track_id) + message = self._html_search_regex( + r'(?s)]+class="global-message cloudcast-disabled-notice-light"[^>]*>(.+?)<(?:a|/div)', + webpage, 'error message', default=None) + preview_url = self._search_regex( - r'\s(?:data-preview-url|m-preview)="([^"]+)"', webpage, 'preview url') + r'\s(?:data-preview-url|m-preview)="([^"]+)"', + webpage, 'preview url', default=None if message else NO_DEFAULT) + + if message: + raise ExtractorError('%s said: %s' % (self.IE_NAME, message), expected=True) + song_url = re.sub(r'audiocdn(\d+)', r'stream\1', preview_url) song_url = song_url.replace('/previews/', '/c/originals/') if not self._check_url(song_url, track_id, 'mp3'): -- 2.22.2