+ def _real_initialize(self):
+ self._login()
+
+ def _login(self):
+ (username, password) = self._get_login_info()
+ if username is None:
+ return
+ self.report_login()
+ webpage = self._download_webpage(self._LOGIN_URL, None, False)
+ form = self._hidden_inputs(webpage)
+ form.update({
+ 'user[email]': username,
+ 'user[password]': password
+ })
+ login_response = self._download_webpage(
+ sanitized_Request(self._LOGIN_URL, urlencode_postdata(form), {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Referer': self._LOGIN_URL
+ }), None, False, 'Wrong login info')
+
+ # Check the login response from Tumblr for an error message and fail the extraction if we find one.
+ login_errors = self._search_regex(r'Tumblr\.RegistrationForm\.errors\s*=\s*\[[\"|\'](.+)[\"|\']\]', login_response, 'login errors', False)
+ if login_errors:
+ raise ExtractorError('Error logging in: %s' % login_errors, expected=True)
+