diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2012-09-27 10:56:25 -0700 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2012-09-27 10:56:25 -0700 |
commit | df09e5f9e11fdea4df36891f8cbb9d3cc95f56c4 (patch) | |
tree | 5bec5ae357a885d6c14ff3d0f5adcbd5d9bbc3a8 /youtube_dl | |
parent | 85f76ac90ba36bdf408a6dc6d54c613de136e0bb (diff) | |
parent | ea46fe2dd441a659e9748abc5727e568583bc6e7 (diff) |
Merge pull request #405 from hdclark/master
Support for custom user agent
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/__init__.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 5ed453bf7..180a0707d 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -190,6 +190,8 @@ def parseOpts(): general.add_option('--dump-user-agent', action='store_true', dest='dump_user_agent', help='display the current browser identification', default=False) + general.add_option('--user-agent', + action='store', dest='useragent', help='specify a custom user agent') general.add_option('--list-extractors', action='store_true', dest='list_extractors', help='List all supported extractors and the URLs they would handle', default=False) @@ -370,7 +372,10 @@ def _real_main(): jar.load() except (IOError, OSError), err: sys.exit(u'ERROR: unable to open cookie file') - + # Set user agent + if opts.useragent is not None: + std_headers['User-Agent'] = opts.useragent + # Dump user agent if opts.dump_user_agent: print std_headers['User-Agent'] |