diff options
| author | yuzu-eva <cafebabe@disroot.org> | 2025-05-08 14:01:37 +0200 |
|---|---|---|
| committer | yuzu-eva <cafebabe@disroot.org> | 2025-05-08 14:01:37 +0200 |
| commit | ef7c1605a027b52bbff1b01ea693b60f53fa3a71 (patch) | |
| tree | 1089334258aefbd459d18cf6968e78f1194739b0 /ytdl | |
initial commit
Diffstat (limited to 'ytdl')
| -rwxr-xr-x | ytdl | 74 |
1 files changed, 74 insertions, 0 deletions
@@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +help() { + echo -e " +Usage: ytdl [-h|-m|-a|-r|-c|-n fileName|-u URL] + +Multipurpose bash script for yt-dlp. Provides options to choose between +downloading videos, downloading music, archiving videos and saves them in the +appropriate directory. By default, the script will take the URL currently in the +clipboard. This makes it possible to bind this script to a keybind in dwm. You +can also explicitly specify a URL. +Defaults to downloading videos. + +Options: + -h Display this help message + -m Download music, save to /media/hdd/music/Youtube Downloads/ + -a Archive video, save to /media/seagate/vids/archives/%(uploader)s/ + -r Download very short reaction clip, save to /media/hdd/pics/reactions/gif/ + -c Passes cookies from firefox to download age-restricted content + -n Specify file name + -u Specify URL +" +} + +# get url from clipboard +url="$(xclip -o)" + +# default output path and filename. +# used for calling this script as keyboard shortcut +path="/media/seagate/vids/random/" +filename="%(title)s" + +opts="--remux-video mkv" + +while getopts ":hmarcn:u:" option; do + case $option in + h) # print help + help + exit + ;; + m) # download music + path="/media/hdd/music/Youtube Downloads/" + opts="-x --audio-format mp3 --download-archive $HOME/.config/yt-dlp/history.txt" + ;; + a) # archive video + path="/media/seagate/vids/archives/%(uploader)s/" + filename="%(upload_date)s - %(title)s" + opts="$opts --download-archive $HOME/.config/yt-dlp/history.txt" + ;; + r) # download reaction clip + path="/media/hdd/pics/reactions/gif/" + opts="--recode-video webm" + ;; + c) # pass cookies for age restricted content + opts="$opts --cookies-from-browser firefox" + ;; + n) # set filename + filename=$OPTARG + ;; + u) # set url + url=$OPTARG + ;; + \?) #invalid option + echo "Error: Invalid option -$OPTARG" >&2 + exit 1 + ;; + :) # empty optarg + echo "Option -$OPTARG requires an argument" >&2 + exit 1 + ;; + esac +done + +yt-dlp -o "$path$filename.%(ext)s" $opts $url |
