Skip to content

Instantly share code, notes, and snippets.

@r3code
Last active May 12, 2025 18:40
Show Gist options
  • Save r3code/8a2ec623e3f556514928d77ddcae93de to your computer and use it in GitHub Desktop.
Save r3code/8a2ec623e3f556514928d77ddcae93de to your computer and use it in GitHub Desktop.
kinescope.io video downloader

kinescope.io video downloader

  1. Install python3, download tools: ffmpeg and N_m3u8DL-RE
  2. Put kdl.py, ffmpeg and N_m3u8DL-RE into same folder
  3. Run python kdl.py it will ask you to input kinescope embed link (e.g. https://kinescope.io/embed/1234534) and referrer link (e.g. https://videos.mysite.org). kinescope forbids to access without a referrer.
  4. Wait for a download copletion.

kdl.py can automatically select the best quality of a video or you can choose it in a menu provided by N_m3u8DL-RE.
ffmpeg receives parts of the selected video and an audio and muxes them into output mp4 file.

Use your Browser developer tools to find a request to https://kinescope.io/embed/ an use in the script.

If you faced dash error

Best option to make sure that you are providing right referrer and embedded link is:

  1. Open in chrome
  2. Press F12
  3. Open your webpage, what you want to download
  4. Press ctrl+ F, and type "u0026"
  5. You will find list of urls, which contains videos. In Header tab you can grab right referrer and embedded link.
  6. If dash = re.findall(r'dash: {"src":"(.?)"', resp)[0].strip() still fails, then switch to response tab and find link, which contains "u0026" (what you found on step 4) , it wll loks like : https://kinescope.io/29402382-ec45-4ea0-b45f-be4fc4f34ff5/master.m3u8?expires=1731320757\u0026token= , without "\u0026token=" it exactly string , what code dash = re.findall(r'{"src":"(.?)"', resp)[0].strip() is trying to find, so just hardcode it

Thanks to @kunter

import requests
import re
import subprocess
m3u8DL_RE_path = 'N_m3u8DL-RE.exe'
link = input('\nkinescope embed link: ')
referrer_link = input('\nreferrer link: ')
select_best = input('\nselect best quality automatically (y/n) [hit ENTER to decline]: ')
headers = {
'authority': 'kinescope.io',
'referer': referrer_link,
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
}
resp = requests.get(link, headers=headers).text
try:
title = re.findall(r'<title>(.*?)</title>', resp)[0].strip()
print(title)
except IndexError:
title = input('video title: ')
dash = re.findall(r'dash: {\"src\":\"(.*?)\"', resp)[0].strip()
dash = re.sub(r'\\u0026', r'&', dash)
print(f'\nmpd link:\n{dash}\n')
run_args = [m3u8DL_RE_path, '--concurrent-download', '-H', 'referer: '+link+'', '--log-level', 'INFO', '--del-after-done', '-M', 'format=mp4:muxer=ffmpeg', '--save-name', title, dash]
if select_best.lower().strip() == 'y':
run_args.append('--auto-select')
subprocess.run(run_args)
@r3code
Copy link
Author

r3code commented Nov 26, 2024

@kunter Thanks for your contribution! Added your workaround as a Reame part.

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