Closed Loukious closed 1 month ago
When streaming something that is handled by mpv's youtube-dl backend, there are two places where you can set the user agent:
mpv.MPV(..., ytdl_raw_options="user-agent=foobar")
.mpv.MPV(..., user_agent="foobar")
.You probably want to use both.
When streaming something that is handled by mpv's youtube-dl backend, there are two places where you can set the user agent:
- You can set the user agent that youtube-dl will use to fetch the page and extract the stream URL. That you set by passing
mpv.MPV(..., ytdl_raw_options="user-agent=foobar")
.- You can set the user agent that mpv will later use to fetch the stream URL that youtube-dl has extracted. That you set by passing
mpv.MPV(..., user_agent="foobar")
.You probably want to use both.
Thank you that seems to be the case. But now I'm facing another issue, the user-agent I'm using contains some non ASCII characters
which seems to cause this error:
ValueError: ('Invalid value for mpv option', -7, (<MpvHandle object at 0x0000021D7D603350>, b'ytdl-raw-options', b'user-agent=\xe2\x80\x8e Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.37 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.37 \xe2\x80\x8e \xe2\x80\x81'))
The non-ascii characters there are unicode bidi control characters. You should delete them, they don't belong in the user agent string.
The non-ascii characters there are unicode bidi control characters. You should delete them, they don't belong in the user agent string.
I'm aware but they are required by the server (that I have no access to in order to change the user-agent whitelist). Any user-agent other than that is blocked.
Oof, lol. I'll push a release tonight that will add support for arbitrary binary data in properties. In the meantime, you can use the current main branch with the code below.
player = mpv.MPV()
player.user_agent = ua
player.ytdl_raw_options = {'user-agent': ua}
Oof, lol. I'll push a release tonight that will add support for arbitrary binary data in properties. In the meantime, you can use the current main branch with the code below.
player = mpv.MPV() player.user_agent = ua player.ytdl_raw_options = {'user-agent': ua}
Works great. Thank you.
I tried both
player['user-agent'] = "MyCustomUserAgent/1.0"
andplayer = mpv.MPV(log_handler=my_log, ytdl=True, user_agent="MyCustomUserAgent/1.0", loglevel='debug')
and both don't seem to modify the user-agent. Is there a solution for this?