]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[generic] Follow redirects specified by `Refresh` HTTP header
authorSergey M․ <dstftw@gmail.com>
Tue, 17 Mar 2015 17:51:40 +0000 (23:51 +0600)
committerSergey M․ <dstftw@gmail.com>
Tue, 17 Mar 2015 17:51:40 +0000 (23:51 +0600)
youtube_dl/extractor/generic.py

index 4e6927b08b032718e09fdbe0b35595456d587156..0b8d96c2724004415f2f2358ae53e71422fbe376 100644 (file)
@@ -1270,8 +1270,14 @@ class GenericIE(InfoExtractor):
         if not found:
             found = re.search(
                 r'(?i)<meta\s+(?=(?:[a-z-]+="[^"]+"\s+)*http-equiv="refresh")'
-                r'(?:[a-z-]+="[^"]+"\s+)*?content="[0-9]{,2};url=\'?([^\'"]+)',
+                r'(?:[a-z-]+="[^"]+"\s+)*?content="[0-9]{,2};\s*(?:URL|url)=\'?([^\'"]+)',
                 webpage)
+            if not found:
+                # Look also in Refresh HTTP header
+                refresh_header = head_response.headers.get('Refresh')
+                if refresh_header:
+                    found = re.search(
+                        r'[0-9]{,2};\s*(?:URL|url)=(.+)', refresh_header)
             if found:
                 new_url = found.group(1)
                 self.report_following_redirect(new_url)