]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[vk] Improve login
authorSergey M․ <dstftw@gmail.com>
Wed, 13 Jul 2016 14:52:52 +0000 (21:52 +0700)
committerSergey M․ <dstftw@gmail.com>
Wed, 13 Jul 2016 14:52:52 +0000 (21:52 +0700)
youtube_dl/extractor/vk.py

index bcb7df83d1c64308d0a78e58e4837dbfef7cd0a5..3ee66e23e22b1d5350148d5cb21c2f55e4885f75 100644 (file)
@@ -53,13 +53,14 @@ class VKBaseIE(InfoExtractor):
         # We will workaround this VK issue by resetting the remixlhk cookie to
         # the first one manually.
         cookies = url_handle.headers.get('Set-Cookie')
-        if sys.version_info[0] >= 3:
-            cookies = cookies.encode('iso-8859-1')
-        cookies = cookies.decode('utf-8')
-        remixlhk = re.search(r'remixlhk=(.+?);.*?\bdomain=(.+?)(?:[,;]|$)', cookies)
-        if remixlhk:
-            value, domain = remixlhk.groups()
-            self._set_cookie(domain, 'remixlhk', value)
+        if cookies:
+            if sys.version_info[0] >= 3:
+                cookies = cookies.encode('iso-8859-1')
+            cookies = cookies.decode('utf-8')
+            remixlhk = re.search(r'remixlhk=(.+?);.*?\bdomain=(.+?)(?:[,;]|$)', cookies)
+            if remixlhk:
+                value, domain = remixlhk.groups()
+                self._set_cookie(domain, 'remixlhk', value)
 
         login_page = self._download_webpage(
             'https://login.vk.com/?act=login', None,