Open download-with-yd-dlp in Script Kit

// Name: Download video with yt-dlp
// Description: Download video with yt-dlp
// Author: Ricardo Gonçalves Bassete
import "@johnlindquist/kit"
const outDir = home('Downloads', 'yt-dlp')
const flags = {
mp4: `-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" -o "%(title)s.mp4"`,
mp3: `-o "%(title)s.mp3" -x --audio-format mp3 --audio-quality 0`,
}
const videoURl = await arg({
placeholder: 'Video URL',
alwaysOnTop: true
})
const format = await arg({
placeholder: 'Select format',
alwaysOnTop: true,
choices: Object.keys(flags),
strict: true
})
await hide()
await ensureDir(outDir)
cd(outDir)
await exec(`yt-dlp ${flags[format]} "${videoURl}"`)
notify({
title: 'Finished downloading video',
message: `Location: ${outDir}`
})