Eric Stdlib
Eric Stdlib

Reputation: 1562

How to set HTTP User-Agent for VLC?

I am using VLC's command line option --http-user-agent, but it does not seem to work.

My command is

$ vlc --http-user-agent 'FooBar/1.2.3' 'http://wiki.videolan.org/'

And when I use tcpdump -Xlnn dst port 80 to capture the packets, I see

0x0030:  8eff 035b 4745 5420 2f20 4854 5450 2f31  ...[GET./.HTTP/1
0x0040:  2e31 0d0a 486f 7374 3a20 7769 6b69 2e76  .1..Host:.wiki.v
0x0050:  6964 656f 6c61 6e2e 6f72 670d 0a41 6363  ideolan.org..Acc
0x0060:  6570 743a 202a 2f2a 0d0a 4163 6365 7074  ept:.*/*..Accept
0x0070:  2d4c 616e 6775 6167 653a 207a 685f 434e  -Language:.zh_CN
0x0080:  0d0a 5573 6572 2d41 6765 6e74 3a20 564c  ..User-Agent:.VL
0x0090:  432f 332e 302e 3220 4c69 6256 4c43 2f33  C/3.0.2.LibVLC/3
0x00a0:  2e30 2e32 0d0a 5261 6e67 653a 2062 7974  .0.2..Range:.byt
0x00b0:  6573 3d30 2d0d 0a0d 0a                   es=0-....

which means that the User-Agent part is not changed (still the default of VLC).

Am I misunderstanding the usage of this option? Or is this a bug in VLC?

My version is VLC media player 3.0.2 Vetinari (revision 3.0.2-0-gd7b653cf14)

Upvotes: 10

Views: 44762

Answers (4)

Matt Aimonetti
Matt Aimonetti

Reputation: 1122

And here is another example, this time using a VLC playlist file (xspf):

<?xml version="1.0" encoding="UTF-8"?>
<playlist xmlns="http://xspf.org/ns/0/" xmlns:vlc="http://www.videolan.org/vlc/playlist/ns/0/" version="1">
    <title>Playlist</title>
    <trackList>
        <track>
            <location>https://radionova.ice.infomaniak.ch/radionova-256.aac</location>
            <extension application="http://www.videolan.org/vlc/playlist/0">
                <vlc:id>0</vlc:id>
              <vlc:option>http-user-agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'</vlc:option>
            </extension>
        </track>
    </trackList>
    <extension application="http://www.videolan.org/vlc/playlist/0">
        <vlc:item tid="0"/>
    </extension>
</playlist>

The important information being <vlc:option>http-user-agent='whatever-UA'</vlc:option>

Upvotes: 1

Roy Shilkrot
Roy Shilkrot

Reputation: 3548

I was able to set the User-Agent only using a LUA script: (where the command line methods didn't work)

$ cat play.lua 
#EXTVLCOPT:http-user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.25 Safari/537.36
#EXTVLCOPT:http-referrer=https://playme.com/i-came-from-this-page-i-sware
https://playme.com/give/me/this/file/169839.mp4?token=my-token

$ VLC play.lua

Upvotes: 2

mathew11
mathew11

Reputation: 3580

$ vlc 'http://wiki.videolan.org/' :http-user-agent='FooBar/1.2.3' seems to do the trick (replaced -- by : and put the attribute after the url). I guess this is probably the way how the windows version expects the attributes, since in the GUI, you also have to add those attributes starting with : (I've only evaluated this from the VLC debug logs)

Upvotes: 10

Dai
Dai

Reputation: 155250

VLC's command-line argument help page's states you need to use = to associate a value with an argument name.

https://wiki.videolan.org/VLC_command-line_help/

 --http-user-agent=<string> User agent

Try this:

$ vlc --http-user-agent='FooBar/1.2.3' 'http://wiki.videolan.org/'

Upvotes: 0

Related Questions