Skip to content

Instantly share code, notes, and snippets.

@franga2000
Last active February 8, 2021 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franga2000/688d6062b3006c3703d0bfb2d7dd626d to your computer and use it in GitHub Desktop.
Save franga2000/688d6062b3006c3703d0bfb2d7dd626d to your computer and use it in GitHub Desktop.

Manually downloading from RTV 4D

  1. Open devtools and refresh the video page

  2. Take playlist URL from devtools

Example: https://vodstr.rtvslo.si/encrypted05/_definst_//2018/12/21/174584131.smil/chunklist_w1881490815_b1800000.m3u8?keylockhash=BoyBlrQaOuIS-M1dIJWPin1ZErxDmzOWONB75xKL2c0

  1. Download that file and save it here as list.m3u

  2. Prefix all lines in the file that don't start with # and start with media_, with the begining of the above URL (up to the last /)

Example:

  • Prefix: https://vodstr.rtvslo.si/encrypted05/_definst_//2018/12/21/174584131.smil/
  • Before: media_w2141640485_b1800000_6.ts?keylockhash=mGs19v8oXZ5bVDcCR50MFkj97MHB3XyoHQJO35g_i3M
  • After: https://vodstr.rtvslo.si/encrypted05/_definst_//2018/12/21/174584131.smil/media_w2141640485_b1800000_6.ts?keylockhash=mGs19v8oXZ5bVDcCR50MFkj97MHB3XyoHQJO35g_i3M

You can do that quickly using search-replace with RegExpr enabled (most text editors can do this):
Search: ^media_ Replace: URL_PREFIX/media_

  1. run this:
ffmpeg -y \
	-protocol_whitelist "file,http,https,tcp,tls" \
	-v warning \
	-loglevel debug \
	-i "list.m3u" \
	-vcodec copy \
	-c copy -f mpegts out.ts

RTV SLO 4D archive reverse-engineering

Input URL

Only the file portion (after last /) of the URL is important - it's the VOD_ID.

The video is embedded via iframe, so we want to request that URL instead: "https://4d.rtvslo.si/embed/ VOD_ID".

Example:

Input: https://4d.rtvslo.si/arhiv/sledi/174584131
VOD_ID: 174584131
Embed URL: https://4d.rtvslo.si/embed/174584131

Authorization

We need 2 things:

  1. A client identifier, valid per-session CLIENT_ID
  2. A token, valid per-clip JWT

Client ID

Included as JavaScript in the embed page.

Around line 254:

options['client'] = "82013fb3a531d5414f478747c1aca622";

JWT

Requested using CLIENT_ID at "https://api.rtvslo.si/ava/getRecordingDrm/`VOD_ID`". Returns JSON object with the token at .response.jwt.

Example:

curl -s 'https://api.rtvslo.si/ava/getRecordingDrm/174584131?client_id=82013fb3a531d5414f478747c1aca622' | jq .response.jwt

Video URLs

Returned from "https://api.rtvslo.si/ava/getMedia/ VOD_ID" as JSON

The key .response.addaptiveMedia.hls (sic) here contains a URL to an M3U8 file, which we can then download using already implemented functions.

Example:

curl -s 'https://api.rtvslo.si/ava/getMedia/174584131?client_id=82013fb3a531d5414f478747c1aca622&jwt=LaLOtvhVRdJh2TUZ23ShL9EvIJsjF6syZ1fwKz0Urqw'  | jq .response.addaptiveMedia.hls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment