Proper support for changing User-Agents from IEs
[youtube-dl] / youtube_dl / utils.py
index 8f856ee8c073dd9095f2b62b1567eabdb321c117..08be9e6373f6d4129327a6125b7d3b8c863273c0 100644 (file)
@@ -450,7 +450,8 @@ class PostProcessingError(Exception):
     This exception may be raised by PostProcessor's .run() method to
     indicate an error in the postprocessing task.
     """
-    pass
+    def __init__(self, msg):
+        self.msg = msg
 
 class MaxDownloadsReached(Exception):
     """ --max-downloads limit has been reached. """
@@ -523,6 +524,11 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
             if 'Accept-encoding' in req.headers:
                 del req.headers['Accept-encoding']
             del req.headers['Youtubedl-no-compression']
+        if 'Youtubedl-user-agent' in req.headers:
+            if 'User-Agent' in req.headers:
+                del req.headers['User-Agent']
+            req.headers['User-Agent'] = req.headers['Youtubedl-user-agent']
+            del req.headers['Youtubedl-user-agent']
         return req
 
     def http_response(self, req, resp):