Skip to content
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

How to set user agent in embedded python script ? #7830

Closed
crhuber opened this issue Dec 10, 2015 · 2 comments
Closed

How to set user agent in embedded python script ? #7830

crhuber opened this issue Dec 10, 2015 · 2 comments

Comments

@crhuber
Copy link

@crhuber crhuber commented Dec 10, 2015

I am calling youtube-dl from a python script. Like so:

from __future__ import unicode_literals
import youtube_dl

ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
    'key': 'FFmpegExtractAudio',
    'preferredcodec': 'mp3',
    'preferredquality': '192',
}],
'logger': MyLogger(),
'progress_hooks': [my_hook],
}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['http://www.youtube.com/watch?v=BaW_jenozKc'])

However, I want to specifically set the user agent to be that of iOS Safari. How would i set the option for user agent? I do not see that as an available option here https://github.com/rg3/youtube-dl/blob/master/youtube_dl/YoutubeDL.py#L117-L265

@phihag
Copy link
Contributor

@phihag phihag commented Dec 10, 2015

Can you elaborate why you want to do that? If some website works better when given another user agent, I'd very much improve youtube-dl to always set the user agent for the website.

@crhuber
Copy link
Author

@crhuber crhuber commented Dec 10, 2015

@phihag from what I understand some websites return different encoded videos depending on your user agent string. I could be wrong on that. But, when I use youtube_dl from Linux to download a video from bbc.co.uk it is unplayable on QuickTime in mac.

@crhuber crhuber closed this Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.