- request = sanitized_Request(
- self._LOGIN_URL, urlencode_postdata(login_form))
- response = self._download_webpage(
- request, None, 'Logging in')
+ try:
+ response = self._download_json(
+ 'https://www.dramafever.com/api/users/login', None, 'Logging in',
+ data=json.dumps(login_form).encode('utf-8'), headers={
+ 'x-consumer-key': self._consumer_secret,
+ })
+ except ExtractorError as e:
+ if isinstance(e.cause, compat_HTTPError) and e.cause.code in (403, 404):
+ response = self._parse_json(
+ e.cause.read().decode('utf-8'), None)
+ else:
+ raise
+
+ # Successful login
+ if response.get('result') or response.get('guid') or response.get('user_guid'):
+ return