[udemy] Don't pollute default headers dict
authorSergey M․ <dstftw@gmail.com>
Mon, 17 Sep 2018 15:14:53 +0000 (22:14 +0700)
committerSergey M․ <dstftw@gmail.com>
Mon, 17 Sep 2018 15:14:53 +0000 (22:14 +0700)
youtube_dl/extractor/udemy.py

index 79c45f80e0f827d07a2ef362597b6e7fbab122e7..105826e9bb04d8b0e39e2126f637607cc8f6159b 100644 (file)
@@ -122,7 +122,9 @@ class UdemyIE(InfoExtractor):
             raise ExtractorError(error_str, expected=True)
 
     def _download_webpage_handle(self, *args, **kwargs):
-        kwargs.setdefault('headers', {})['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4'
+        headers = kwargs.get('headers', {}).copy()
+        headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4'
+        kwargs['headers'] = headers
         return super(UdemyIE, self)._download_webpage_handle(
             *args, **compat_kwargs(kwargs))