4

Let's say that I'm listening to an audio file online by pointing my web browser to some url https://someurl.fr/file.oga. So the file isn't embedded in a page, but is accessed directly by the browser. Usually, I could then download that file with Ctrl+S or "Save as". But when I do that, I end up with a local file that plays fine, but only contains about 5mn out of the 30mn that I can listen to online. And that's the better case, using Firefox. With Chromium, saving the file locally fails entirely. Using curl, I also get only the first 5mn of the audio.

Upon closer inspection, it appears that the url doesn't return an HTTP status "200 OK", but rather "206 Partial Content", which I guess is the cause of my issue.

Since I'm still able to listen to the whole file online, I would imagine that there is some way to download it entirely, but I couldn't find one.

2 Answers2

0

You can use the popular tool curl to do this. curl handles servers which respond with 206 Partial Content seemlessly.

For example:

curl https://example.com/mylargevideofile.mp4 -o /dev/null

Just works

Cherona
  • 443
0

@Cherona answer is to the point. However I would like to add to it that. There may be some servers that may disregard the request if specific headers aren't present.

If you've found out that the response is 206 Partial Content from the dev tools, then you may as well copy the request as a curl request like so

DevTools Screenshot

So if I need to send a header with Referrer: foobar.com I do this -

curl 'https://foobar.com/997/JR4e7mE3/Y7c2Brma_720p.mp4' \
  -H 'Referer: https://www.foobar.com/' \
  -H 'Accept-Language: en-GB,en;q=0.9,en-US;q=0.8' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Range: bytes=0-' \
  -H 'sec-ch-ua: "Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Linux"' -o test6.mp4

Notice in the header Range is set to bytes=0- which requests the server to send from 0th byte till the last byte.

You can read more about HTTP Status Code 206 here