From 8dbfcf1dce73fa42312cdc36872dedcc88a9bab7 Mon Sep 17 00:00:00 2001 From: Tangent Date: Sat, 13 Jan 2024 04:04:00 -0700 Subject: [PATCH] added video download manager --- video-dl.lua | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 video-dl.lua diff --git a/video-dl.lua b/video-dl.lua new file mode 100644 index 0000000..eef505f --- /dev/null +++ b/video-dl.lua @@ -0,0 +1,57 @@ +#!/usr/bin/env luajit + +local helptext = [[Usage: + + ./video-dl.lua [action] + +[action]: What is desired. + video (default): Highest quality video (maximum 720p). + backup, clone, copy: English subtitles (including automatic + subtitles), thumbnail, description, highest quality video + (maximum 720p). + music, audio: Highest quality audio only. + metadata, meta: English subtitles (including automatic + subtitles), thumbnail, description. +: Source. YouTube URL expected, but should work with anything + yt-dlp works with. +]] + +local action, url + +if #arg < 2 then + if arg[1]:find("help") then + print(help) + return false + end + action = "video" + url = arg[1] +else + action = arg[1] + url = arg[2] +end + +local execute = { + backup = function() + os.execute("yt-dlp --retries 100 --write-sub --write-auto-sub --sub-lang \"en.*\" --write-thumbnail --write-description -f \"bestvideo[height<=720]+bestaudio/best[height<=720]\" \"" .. url .."\"") + end, + music = function() + os.execute("yt-dlp --retries 100 -x --audio-quality 0 \"" .. url .."\"") + end, + metadata = function() + os.execute("yt-dlp --retries 100 --write-sub --write-auto-sub --sub-lang \"en.*\" --write-thumbnail --write-description --skip-download \"" .. url .."\"") + end, + video = function() + os.execute("yt-dlp --retries 100 -f \"bestvideo[height<=720]+bestaudio/best[height<=720]\" \"" .. url .. "\"") + end, +} +execute.clone = execute.backup +execute.copy = execute.backup +execute.audio = execute.music +execute.meta = execute.metadata + +if execute[action] then + execute[action]() +else + print("Invalid ") + print("Received:", "action", action, "url", url) +end