|
#!C:\Python310\python.exe |
|
import subprocess |
|
import sys |
|
|
|
# This is a python script that can be used as a fake `ffmpeg` binary. |
|
# Remove `.py` from the file extension and change the shebang above to point to your Python installation. |
|
# Then pass this as the ffmpeg binary to any script or software that can take an ffmpeg binary for various use. |
|
|
|
# If the program doesnt honor the shebang or complains, try with a .cmd or .bat file with: |
|
# @echo off |
|
# "C:\Python310\python.exe" "%~dp0\ffdecrypt" %* |
|
# and make sure that file is saved right next to the `ffdecrypt` file. |
|
|
|
# Doing this has the benefit of being able to MiTM the arguments for modification or injection of new args. |
|
# Its currently setup to do similar re-stream + cenc decrypt as the other methods shown here. |
|
|
|
# The code related to audio, video variables (mappings) may not be wanted for your use-case but I recommend them |
|
# in most cases. For example xTeVe will choose the first-found track of each track type and use exclusively that. |
|
# So to get around that we map the only track of each track type as the best tracks, then xTeVe has no choice but |
|
# to use the best tracks. |
|
|
|
|
|
DRM_CONTENT_KEYS = { |
|
"rte": { |
|
"channel1": "REDACTED", |
|
"channel2": "REDACTED", |
|
"channel3": "REDACTED", |
|
"channel4": "REDACTED" |
|
}, |
|
"channel4": { |
|
"c4": "REDACTED", |
|
"e4": "REDACTED", |
|
"m4": "REDACTED", |
|
"f4": "REDACTED", |
|
"4s": "REDACTED" |
|
}, |
|
"channel5": { |
|
"channel5": "REDACTED", |
|
"5usa": "REDACTED" |
|
}, |
|
"itv": { |
|
"itv1": "REDACTED", |
|
"itv2": "REDACTED", |
|
"itv3": "REDACTED", |
|
"itv4": "REDACTED", |
|
"itvbe": "REDACTED", |
|
"citv": "REDACTED" |
|
} |
|
} |
|
|
|
ffmpeg_args = sys.argv[1:] |
|
url_index = ffmpeg_args.index("-i") + 1 |
|
url = ffmpeg_args[url_index] |
|
|
|
service, channel = None, None |
|
video, audio = None, None |
|
|
|
if "c4ukdash-eb.tls1.yospace.com" in url: |
|
# e.g., https://csm-e-c4ukdash-eb.tls1.yospace.com/csm/extlive/channelfour01,c4-v2-iso-dash-h12.mpd |
|
service = "channel4" |
|
channel = url.split("channelfour01,")[1].split("-")[0] |
|
video, audio = 6, 1 |
|
elif "live.rte.ie" in url: |
|
# e.g., https://live.rte.ie/live/a/channel1/channel1.isml/.mpd |
|
service = "rte" |
|
channel = url.split("/")[-2].split(".isml")[0] |
|
video, audio = 6, 0 |
|
elif "simadotcomitv.com" in url or "simamobile.itv.com": |
|
# e.g., https://itv1simamobile.itv.com/playout/mb01/itv1/cenc.isml/.mpd?... (or itv1simadotcom.itv.com and such) |
|
service = "itv" |
|
channel = url.split("/")[2].split("sima")[0] |
|
video, audio = 5, 0 |
|
elif url.startswith("https://akadashlive-c5", "https://akadashlive-5usa", "https://akadashlive-5star", "https://akadashlive-paramount", "https://akadashlive-5select"): |
|
# e.g., https://akadashlive-c5.akamaized.net/out/v1/07646f4532504e45a2a8647f59372d1c/index.mpd |
|
service = "channel5" |
|
channel = url.split(".")[0].split("-")[-1] |
|
video, audio = 4, 0 |
|
|
|
if audio is not None: |
|
ffmpeg_args.insert(url_index + 1, "-map") |
|
ffmpeg_args.insert(url_index + 2, f"0:a:{audio}") |
|
if video is not None: |
|
ffmpeg_args.insert(url_index + 1, "-map") |
|
ffmpeg_args.insert(url_index + 2, f"0:v:{video}") |
|
|
|
if service and channel: |
|
content_key = DRM_CONTENT_KEYS[service][channel] |
|
ffmpeg_args = ["-re", "-cenc_decryption_key", content_key] + ffmpeg_args |
|
|
|
subprocess.Popen(["ffmpeg.exe", *ffmpeg_args]) |