Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Grab TV series from iVysilani with CC and AD
#!/usr/bin/env python3
import subprocess
import youtube_dl
import click
from pprint import pprint
@click.option("--first", type=int, default=1)
@click.option("--last", type=int, default=1)
@click.option("--outbase", default="E{:02d}.mkv")
def main(base_url, first, last, outbase):
"""Download TV series from iVysilani"""
fnames = {
"video": ".mp4", "audio": ".m4a", "ad": ".m4a", "cc": ".srt"
def my_hook(d):
if d["status"] == "finished":
fn = d["filename"]
if fn.endswith("-NA.mp4"):
fnames["video"] = fn
fnames["cc"] = fn[:-3] + ""
elif fn.endswith("-ces.m4a"):
fnames["audio"] = fn
elif fn.endswith("-que.m4a"):
fnames["ad"] = fn
ydl_opts = {
"format": "bestvideo,bestaudio,dash-audioDescription-1002-1507",
"writesubtitles": True,
"outtmpl": "%(title)s-%(id)s-%(language)s.%(ext)s",
"progress_hooks": [my_hook],
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
for i in range(first, last+1):[base_url.format(i)])
outname = outbase.format(i)[
"mkvmerge", "-o", outname, fnames["video"],
"--language", "0:cze", fnames["audio"],
"--language", "0:cze", "--track-name",
"0:\"audio description\"", fnames["ad"],
"--default-track", "0:0",
"--language", "0:cze", "--track-name",
"0:\"closed captions\"", fnames["cc"],
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment