aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorhdclark <hdclark@ualberta.ca>2012-08-22 23:40:35 -0700
committerhdclark <hdclark@ualberta.ca>2012-08-22 23:40:35 -0700
commitea46fe2dd441a659e9748abc5727e568583bc6e7 (patch)
tree6089b60bbd30ab5b3a0603e66debed85039fcbf2 /youtube_dl
parent9bb8dc8e42da4e47008a0acd2a1d69e00193e02d (diff)
downloadyoutube-dl-ea46fe2dd441a659e9748abc5727e568583bc6e7.tar.xz
Added support for custom user agents.
Added a few simple lines to add support for the flag "--user-agent" to pass a custom string to std_header['User-Agent'].
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/__init__.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 86951840d..d457d6b82 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)
@@ -368,7 +370,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']