8

I've used Chrome developer tools to inspect network activity and filter the mpd file. I've get the URL of the mpd with the context menu copy link address. But when I've assembled the youtube-dl command line it get HTTP Error 403: Forbidden.

So I've tried to add the --verbose option to get more information and found a warning "Could not send HEAD request" so I've assumed I needed to send also the headers. I can get the headers with the context menu copy as cURL in the mpd file listed in network activity inspector.

Downloading with curl works for the manifest, but how can I provide headers to youtube-dl to send them properly?

Telesforo X
  • 181
  • 1
  • 1
  • 7

1 Answers1

10

The cURL copy from Chrome developer tools filtered entry in the inspect network activity will provide this kind of string:

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

Just replacing -H with --add-header and curl with youtube-dl and deleting --compressed will do the trick, ending up like this (headers are only examples):

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' \
Telesforo X
  • 181
  • 1
  • 1
  • 7
  • How can you add these headers in windows? – Arete Jul 08 '21 at 19:15
  • 1
    It should work, likely if you have issues is related to the character required to escape other special characters and issue multi-line commands, in windows if you are using cmd it is the caret instead of the backslash. HTH – Telesforo X Jul 19 '21 at 15:55
  • 2
    Just to avoid possibile bother, we could add `--no-check-certificate` – Mimmo May 18 '22 at 08:08