-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for custom user agent #405
Conversation
Added a few simple lines to add support for the flag "--user-agent" to pass a custom string to std_header['User-Agent'].
Note that this will help alleviate issues arising from 'dated' user agents, like issue #390. Also note that using youtube-dl without a custom user agent can be a PITA when, for example, performing
If the website is picky about ensuring the resolver and player have the same user agent. YouTube and Vimeo will occasionally complain about this. |
Oh, just to complement the previous message where I talked about the rebase, you will quite probably have to do a Another solution (probably cleaner) would be to create a branch from |
Hey rbrito, As far I can tell I've re-based my repo to remove the snafu. Github tells me that the original request has been changed to reflect the change to my master branch. Is this suitable? |
Hi, @hdclark. On Sep 25 2012, hdclark wrote:
This looks much cleaner. I think that @ FiloSottile may want to consider Also, while this is a more general solution than mine in issue #390, it Thanks, Rogério Brito : rbrito@{ime.usp.br,gmail.com} : GPG key 4096R/BCFCAAAA |
LGTM, it should work and not conflict with other user_agent stuff, like blip.tv fix. |
Merged. Thanks! |
This isn't working for me -- $ youtube-dl --user-agent "Mozilla/5.0" -e $URL youtube-dl: error: no such option: --user-agent $ youtube-dl --version This is the macports version. |
Same for me (Arch Linux, 9/27.) I think it was packaged prior to merge. If you look at the options, no user agent flag exists. |
I compiled the latest tarball and still get the same result. |
I looked at the source and the user agent code is included in init.py. I'm not sure why it isn't working in the 9/27 binary and haven't a clue about the tarball. You could try cloning the repo - I would think that should work. I'm quite far away from a reasonable machine for a few days so I will have to do more digging after the weekend (holiday in Canada.) |
Upon expection, performing followed by followed by works fine. It appears the packaged binary/tarball simply did not include this pull. Maybe @phihag could comment? |
Should be fixed with the new 2012.10.09 release
works fine (i.e. doesn't say |
[pull] master from ytdl-org:master
What
A few simple lines were added to provide a "--user-agent" option to specify a custom user agent.
How it changes the code
A new variable (opt.useragent) is introduced. No functionality breaks (I think!) As soon as possible, we update std_header['User-Agent'] with the custom user agent string.
How it should be used
How it changes the HTML
Without a custom user agent, we can expect
to yield the GET header
When we specify a custom agent
we get the modified request
Notes
My Python experience is limited. My tests all worked, but please ensure I've not done something silly.