如何将Curl请求参数转换为VLC命令下载需登录视频
问题:VLC加载需登录视频返回HTTP 403,请求将Curl参数转换为VLC参数
背景
我已熟练掌握通过VLC的「Open network stream」图形界面下载视频的方法,成功操作过数十次,仅曾需添加http-referrer参数,其余情况均正常。现在想下载一个需要登录权限的视频(我拥有合法访问权限,仅截取片段),但VLC返回HTTP 403错误。
错误信息
access error: HTTP 403 error
http error: local stream 1 error: Cancellation (0x8)
VLC日志
main debug: resolving video-course.coolsite.com ... gnutls debug: TLS handshake: Resource temporarily unavailable, try again. gnutls debug: TLS handshake: Resource temporarily unavailable, try again. gnutls debug: TLS handshake: Resource temporarily unavailable, try again. gnutls debug: TLS handshake: Resource temporarily unavailable, try again. gnutls debug: TLS handshake: Success. gnutls debug: - safe renegotiation (RFC5746) enabled gnutls debug: - extended master secret (RFC7627) enabled gnutls debug: - false start (RFC7918) enabled http debug: out SETTINGS (0x04) frame of 30 bytes, flags 0x00, global http debug: out HEADERS (0x01) frame of 209 bytes, flags 0x05, stream 1 http debug: in SETTINGS (0x04) frame of 18 bytes, flags 0x00, global http debug: setting: Concurrent streams (0x0003): 128 http debug: setting: Initial window size (0x0004): 65536 http debug: setting: Frame size (0x0005): 16777215 http debug: out SETTINGS (0x04) frame of 0 bytes, flags 0x01, global http debug: in WINDOW_UPDATE (0x08) frame of 4 bytes, flags 0x00, global http debug: in SETTINGS (0x04) frame of 0 bytes, flags 0x01, global http debug: in HEADERS (0x01) frame of 227 bytes, flags 0x04, stream 1 http debug: stream 1 10 headers: http debug: :status: "403" http debug: server: "CloudFront" http debug: date: "Tue, 17 Oct 2023 19:13:56 GMT" http debug: content-type: "text/xml" http debug: content-length: "146" http debug: x-cache: "Error from cloudfront" http debug: via: "1.1 etc.cloudfront.net (CloudFront)" http debug: x-amz-cf-pop: "ABABCDCD-P3" http debug: x-amz-cf-id: "ABCDEF==" http debug: cache-control: "max-age=3600" access error: HTTP 403 error http error: local stream 1 error: Cancellation (0x8) http debug: out RST_STREAM (0x03) frame of 4 bytes, flags 0x00, stream 1 http debug: local shutdown
验证可行性:成功的Curl命令
我已用Curl携带必要Cookie和请求头成功下载包含*.ts文件的播放列表,命令如下:
curl 'https://video-course.coolsite.com/video.m3u8' \ -H 'authority: video-course.coolsite.com' \ -H 'accept: */*' \ -H 'accept-language: en-US,en;q=0.9,de;q=0.8' \ -H 'cache-control: no-cache' \ -H 'cookie: CloudFront-Key-Pair-Id=ABCDEF; cf_clearance=LONGSTRINGCONTINUES; FUP_vid=12345; etc.' \ -H 'dnt: 1' \ -H 'origin: https://www.coolsite.com' \ -H 'pragma: no-cache' \ -H 'referer: https://www.coolsite.com/' \ -H 'sec-ch-ua: "Chromium";v="118", etc.' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'sec-ch-ua-platform: "Linux"' \ -H 'sec-fetch-dest: empty' \ -H 'sec-fetch-mode: cors' \ -H 'sec-fetch-site: same-site' \ -H 'user-agent: Mozilla/5.0 etc.' \ --compressed
尝试的VLC命令框架(未完成)
我尝试过GUI和vlc/cvlc命令行的多种参数(如:cookie='…'、:set-cookie='…'等),但不清楚VLC对应参数的名称,也不确定是否能与Curl参数一一对应,目前的命令框架如下:
cvlc 'https://video-course.coolsite.com/video.m3u8' \ :???='video-course.coolsite.com' (authority) \ :???='*/*' (accept) \ :???='en-US,en;q=0.9,de;q=0.8' (accept-language) \ :???='no-cache' (cache-control) \ :???='CloudFront-Key-Pair-Id=ABCDEF; cf_clearance=LONGSTRINGCONTINUES; FUP_vid=12345; etc.' (cookie) \ :???=1 (dnt) \ :???='https://www.coolsite.com' (origin) \ :???='no-cache' (pragma) \ :http-referrer='https://www.coolsite.com/' \ :???='"Chromium";v="118", etc.' (sec-ch-ua) \ :???='?0' (sec-ch-ua-mobile) \ :???='"Linux"' (sec-ch-ua-platform) \ :???='empty' (sec-fetch-dest) \ :???='cors' (sec-fetch-mode) \ :???='same-site' (sec-fetch-site) \ :http-user-agent='Mozilla/5.0 etc.'
已查阅资料
- 如何为VLC设置HTTP User-Agent
- VLC命令行帮助文档
- VLC HTTP请求头设置相关Issue
- 如何为VLC添加Basic Auth头
请求帮助
需要将上述Curl请求参数转换为有效的VLC参数,解决HTTP 403错误并成功下载视频。
内容的提问来源于stack exchange,提问作者WoodrowShigeru
相关产品推荐
相关产品推荐

