Tel*_*o X 5 stream request-headers youtube-dl
我使用 Chrome 开发人员工具检查网络活动并过滤 mpd 文件。我已经通过上下文菜单复制链接地址获得了 mpd 的 URL。但是当我组装 youtube-dl 命令行时,它会收到 HTTP 错误 403:禁止。
因此,我尝试添加 --verbose 选项以获取更多信息,并发现警告“无法发送 HEAD 请求”,因此我假设我还需要发送标头。我可以在网络活动检查器中列出的 mpd 文件中获取带有上下文菜单副本的标题作为 cURL。
使用 curl 下载适用于清单,但如何向 youtube-dl 提供标头以正确发送它们?
检查网络活动中 Chrome 开发者工具过滤条目的 cURL 副本将提供这种字符串:
curl 'https://source-of-video.net/folder/manifest.mpd' \
-H 'authority: source-of-video.net' \
-H 'pragma: no-cache' \
-H 'cache-control: no-cache' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' \
-H 'dnt: 1' \
-H 'accept: */*' \
-H 'origin: https://origin-website-of-video' \
-H 'sec-fetch-site: cross-site' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-dest: empty' \
-H 'referer: https://origin-website-of-video/origin.html' \
-H 'accept-language: en-US,en;q=0.9,es;q=0.8,it;q=0.7,pt;q=0.6' \
--compressed
Run Code Online (Sandbox Code Playgroud)
只需替换-Hwith--add-header和curlwithyoutube-dl并删除--compressed就可以了,结果是这样的(标题只是示例):
youtube-dl 'https://source-of-video.net/folder/manifest.mpd' \
--add-header 'authority: source-of-video.net' \
--add-header 'pragma: no-cache' \
--add-header 'cache-control: no-cache' \
--add-header 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' \
--add-header 'dnt: 1' \
--add-header 'accept: */*' \
--add-header 'origin: https://origin-website-of-video' \
--add-header 'sec-fetch-site: cross-site' \
--add-header 'sec-fetch-mode: cors' \
--add-header 'sec-fetch-dest: empty' \
--add-header 'referer: https://origin-website-of-video/origin.html' \
--add-header 'accept-language: en-US,en;q=0.9,es;q=0.8,it;q=0.7,pt;q=0.6' \
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7283 次 |
| 最近记录: |