read_arg_paste_read() { local x=$1 [ -z "$x" ] && x=$(pbpaste) [[ $x != http* ]] && read x echo "$x" } youtube_download() { torsocks yt-dlp "$1" --cookies-from-browser safari -t $3 -o $2 } youtube_watch() { local url=$(read_arg_paste_read "$1") local tempfname=$(gmktemp --suffix=.mp4) rm $tempfname echo "Downloading $url to $tempfname" youtube_download "$url" "$tempfname" mp4 open -W $tempfname rm $tempfname }