bash/for_smol/ytmpdplay.sh

37 lines
524 B
Bash
Raw Normal View History

2023-02-14 18:22:28 +00:00
#!/usr/bin/env bash
: "${1?How to use: $0 YT_VIDEO_LINK}"
yt_link="$1"
is_video=$(yt-dlp -g "$yt_link" | wc -l)
if [[ $is_video == 2 ]]
then
play_link=$(yt-dlp -g "$yt_link" | sed '1d')
else
play_link=$(yt-dlp -g "$yt_link")
fi
2023-02-14 18:22:28 +00:00
echo "Clear playlist? (N/y)"
read -r clearplay
2023-02-14 18:22:28 +00:00
case "$clearplay" in
"y")
2023-02-14 18:22:28 +00:00
mpc clear 1>/dev/null
echo "Playlist cleared"
2023-02-14 18:22:28 +00:00
mpc add "$play_link" 1>/dev/null
mpc play 1>/dev/null
echo "Playing"
exit 0
;;
"n")
echo "Adding"
;;
"")
echo "Adding"
;;
esac
mpc add "$play_link" 1>/dev/null
2023-02-14 18:22:28 +00:00
exit 0