#!/bin/sh
# argument ($1) -> clipboard -> stdin
test -z "${inp:=${1:-"$(xclip -sel c -o)"}}" \
&& inp="$(cat /dev/stdin)"
echo "inp: ${inp}" 1>&2
# take last link from clipboard
# works when link is from yt-local
inp="$(echo -n "$inp" | awk -F 'https?://' '{print $NF}')"
echo "inp: ${inp}" 1>&2
notify-send "ytclipo" "downloading $inp"
yt-dlp "$inp" \
-f "b" \
-S "res:720" \
-P "$HOME/vids" \
-o "%(title)s.%(ext)s"
notify-send "ytclipo" "ytclipo
finished downloading."