diff options
author | Sergey M․ <dstftw@gmail.com> | 2018-05-26 20:00:00 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2018-05-26 20:00:00 +0700 |
commit | 97b01144bd9771f224749ffca10156a1cd7e9c1f (patch) | |
tree | b31e9d6f007bedbc92b50ace8d3bbd747014573f | |
parent | 56cd31f32015cce131fb40a112d323da57fdda8e (diff) |
[tumblr] Detect and report sensitive media (closes #13829)
-rw-r--r-- | youtube_dl/extractor/tumblr.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/youtube_dl/extractor/tumblr.py b/youtube_dl/extractor/tumblr.py index 758ccbb44..89e6eb5ab 100644 --- a/youtube_dl/extractor/tumblr.py +++ b/youtube_dl/extractor/tumblr.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import re from .common import InfoExtractor +from ..compat import compat_str from ..utils import ( ExtractorError, int_or_none, @@ -150,11 +151,19 @@ class TumblrIE(InfoExtractor): url = 'http://%s.tumblr.com/post/%s/' % (blog, video_id) webpage, urlh = self._download_webpage_handle(url, video_id) + redirect_url = compat_str(urlh.geturl()) + if 'tumblr.com/safe-mode' in redirect_url or redirect_url.startswith('/safe-mode'): + raise ExtractorError( + 'This Tumblr may contain sensitive media. ' + 'Disable safe mode in your account settings ' + 'at https://www.tumblr.com/settings/account#safe_mode', + expected=True) + iframe_url = self._search_regex( r'src=\'(https?://www\.tumblr\.com/video/[^\']+)\'', webpage, 'iframe url', default=None) if iframe_url is None: - return self.url_result(urlh.geturl(), 'Generic') + return self.url_result(redirect_url, 'Generic') iframe = self._download_webpage(iframe_url, video_id, 'Downloading iframe page') |