Explorar o código

[noco] Modernize

Sergey M․ %!s(int64=8) %!d(string=hai) anos
pai
achega
ad3033037c
Modificáronse 1 ficheiros con 11 adicións e 10 borrados
  1. 11 10
      youtube_dl/extractor/noco.py

+ 11 - 10
youtube_dl/extractor/noco.py

@@ -69,16 +69,17 @@ class NocoIE(InfoExtractor):
         if username is None:
         if username is None:
             return
             return
 
 
-        login_form = {
-            'a': 'login',
-            'cookie': '1',
-            'username': username,
-            'password': password,
-        }
-        request = sanitized_Request(self._LOGIN_URL, urlencode_postdata(login_form))
-        request.add_header('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8')
-
-        login = self._download_json(request, None, 'Logging in as %s' % username)
+        login = self._download_json(
+            self._LOGIN_URL, None, 'Logging in as %s' % username,
+            data=urlencode_postdata({
+                'a': 'login',
+                'cookie': '1',
+                'username': username,
+                'password': password,
+            }),
+            headers={
+                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
+            })
 
 
         if 'erreur' in login:
         if 'erreur' in login:
             raise ExtractorError('Unable to login: %s' % clean_html(login['erreur']), expected=True)
             raise ExtractorError('Unable to login: %s' % clean_html(login['erreur']), expected=True)