diff --git a/.config/scriptrc/youtube.sh b/.config/scriptrc/youtube.sh new file mode 100644 index 0000000..1dc79a0 --- /dev/null +++ b/.config/scriptrc/youtube.sh @@ -0,0 +1,20 @@ +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 +}