authenticationcookieshttprequestvlc

Download password-protected video with vlc


I've learned how to download videos with VLC via the "Open network stream" GUI, and I've done that dozens of times. I once had to add a http-referrer, but otherwise, I never had much trouble with this method.

Now I have this video that I'd like to download which is only accessible after I log in on that website. I do have the proper credentials to view the video, don't worry. I just want to clip a short scene that I like – as I tend to do.

Naturally, vlc only throws 403 errors.

access error: HTTP 403 error
http error: local stream 1 error: Cancellation (0x8)

And from the message window:

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

I've managed to download the playlist (of *.ts files) via a curl request, considering this password protection, the necessary cookie and other headers. This suggests to me that it should technically be possible.

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

But I don't know how to translate that set of parameters to vlc. I've tried various variations via the GUI as well as the vlc and cvlc CLI commands … like :cookie='…', :set-cookie='…' or :http-cookie='…'. But I just don't know the names of the vlc parameters – let alone, whether they would translate 1:1 from curl.

This is what I got:

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.'

Research


Solution

  • I ended up downloading the *.m3u8 and *.ts files via curl, which can then be merged using ffmpeg which I'm already familiar with:

    $ cat segment1_0_av.ts segment2_0_av.ts segment3_0_av.ts > all.ts
    $ ffmpeg -i all.ts -acodec copy -vcodec copy all.mp4
    

    Though I've had trouble telling the GUI to load multiple local files and save it to a single file, VLC on the CLI side can do so too according to this doc page. I haven't tried that one yet.

    > "%PROGRAMFILES%\VideoLAN\VLC\vlc.exe" file1.ps file2.ps file3.ps --sout "#gather:std{access=file,mux=ts,dst=all.ts}" --no-sout-all --sout-keep