[noco] Modernize
authorSergey M․ <dstftw@gmail.com>
Fri, 24 Feb 2017 14:50:13 +0000 (21:50 +0700)
committerSergey M․ <dstftw@gmail.com>
Fri, 24 Feb 2017 14:51:56 +0000 (21:51 +0700)
youtube_dl/extractor/noco.py

index fc0624dd039d1f57952c650ff64ca0359a4880f4..8b83e1f760141bc1a6a0ff4c56761e09b6e3d920 100644 (file)
@@ -69,16 +69,17 @@ class NocoIE(InfoExtractor):
         if username is None:
             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:
             raise ExtractorError('Unable to login: %s' % clean_html(login['erreur']), expected=True)