#!/usr/bin/env bash set -euo pipefail # to use a SOCKS proxy run this in the # background before excuting the script # ssh -D 1080 -C -N user@ip SOCKS_PROXY_URL="socks5://localhost:1080" TWITCH_CHANNELS="christitustech\ntheprimeagen" VIDEO_DIR="$HOME/Videos/youtube/" media=$(echo -e "Video\nStream" | dmenu -p "Media Type: ") quality=$(echo -e "480p\n720p\n1080p" | dmenu -p "Quality: ") socks=$(echo -e "no\nyes" | dmenu -p "use SOCKS? ") if [[ $socks == "yes" ]]; then MPV_COMMAND="alacritty -e mpv --http-proxy="$SOCKS_PROXY_URL"" else MPV_COMMAND="alacritty -e mpv" fi case "$media" in "Video") action=$(echo -e "Stream\nDownload" | dmenu -p "Media Type: ") case "$action" in "Stream") $MPV_COMMAND --save-position-on-quit "--ytdl-format=bestvideo[height<=$quality]+bestaudio" "$(xclip -o -selection clipboard)" ;; "Download") mkdir -p $VIDEO_DIR alacritty -e yt-dlp -f "[height<=$quality]+bestaudio" "$(xclip -o -selection clipboard)" -o "$VIDEO_DIR/%(uploader)s - %(title)s.%(ext)s" ;; esac ;; "Stream") channel=$(echo -e "$TWITCH_CHANNELS" | dmenu -p "Channel: ") $MPV_COMMAND --no-resume-playback "--ytdl-format=bestvideo[height<=$quality]+bestaudio" "https://www.twitch.tv/$channel" ;; esac # TODO: make this work # input=$(echo -n | dmenu -p "YouTube Search: ") # [[ -n $input ]] && st ytfzf -ft --preview-side=right "$input"