#!/bin/bash

FORMAT="(bestvideo[vcodec^=av01][height>=1080][fps>30]/bestvideo[vcodec=vp9.2][height>=1080][fps>30]/bestvideo[vcodec=vp9][height>=1080][fps>30]/bestvideo[vcodec^=av01][height>=1080]/bestvideo[vcodec=vp9.2][height>=1080]/bestvideo[vcodec=vp9][height>=1080]/bestvideo[height>=1080]/bestvideo[vcodec^=av01][height>=720][fps>30]/bestvideo[vcodec=vp9.2][height>=720][fps>30]/bestvideo[vcodec=vp9][height>=720][fps>30]/bestvideo[vcodec^=av01][height>=720]/bestvideo[vcodec=vp9.2][height>=720]/bestvideo[vcodec=vp9][height>=720]/bestvideo[height>=720]/bestvideo)+(bestaudio[acodec=opus]/bestaudio)/best"

OUTPUT="[%(uploader)s] %(title)s [%(upload_date)s - %(id)s].%(ext)s"

EXTENSION="mkv"

for var in "$@"
do
    yt-dlp --limit-rate 5M --external-downloader=aria2c --download-archive "archive.log" -i --add-metadata --all-subs --embed-subs \
	-o "$OUTPUT" --merge-output-format "$EXTENSION" --format "$FORMAT" "$var"
done

