Skip to content

Instantly share code, notes, and snippets.

@divadsn
Last active April 4, 2020 14:29
Show Gist options
  • Select an option

  • Save divadsn/e1e7691b0bc6bb88a0d3680912bb0842 to your computer and use it in GitHub Desktop.

Select an option

Save divadsn/e1e7691b0bc6bb88a0d3680912bb0842 to your computer and use it in GitHub Desktop.
Proof of concept extractor script for cda.pl video links, reverse engineered from updated player.js
import json
import urllib.request
from urllib.parse import unquote
from bs4 import BeautifulSoup
def decrypt(a: str):
a = unquote(a.replace("_XDDD", ""))
b = []
for e in range(len(a)):
f = ord(a[e])
b.append(chr(33 + (f + 14) % 94) if 33 <= f and 126 >= f else chr(f))
a = "".join(b)
a = a.replace(".cda.mp4", "")
a = a.replace(".2cda.pl", ".cda.pl")
a = a.replace(".3cda.pl", ".cda.pl")
return a
if __name__ == '__main__':
url = "https://www.cda.pl/video/416037128"
# Trying to avoid as much trouble as possbile by "mocking" a real browser request
request = urllib.request.Request(url, headers={
"Referer": "http://www.cda.pl",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0"
})
with urllib.request.urlopen(request) as response:
bs4 = BeautifulSoup(response, "html.parser")
tags = bs4.findAll("div")
for tag in tags:
if tag.has_attr("player_data"):
player_data = json.loads(tag["player_data"])
break
file = player_data["video"]["file"]
print("https://" + decrypt(file) + ".mp4")
@divadsn

divadsn commented Mar 30, 2020

Copy link
Copy Markdown
Author

Check the demo here: https://cda.codebucket.de/

Please note that currently some CDNs are working very slow, I am working on a workaround in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment