2023-02-14 18:22:28 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
: "${1?How to use: $0 YT_VIDEO_LINK}"
|
|
|
|
|
|
|
|
yt_link="$1"
|
2023-05-08 22:23:01 +00:00
|
|
|
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
|
|
|
|
2023-05-08 22:23:01 +00:00
|
|
|
echo "Clear playlist? (N/y)"
|
|
|
|
read -r clearplay
|
2023-02-14 18:22:28 +00:00
|
|
|
|
2023-05-08 22:23:01 +00:00
|
|
|
case "$clearplay" in
|
|
|
|
"y")
|
2023-02-14 18:22:28 +00:00
|
|
|
mpc clear 1>/dev/null
|
2023-05-08 22:23:01 +00:00
|
|
|
echo "Playlist cleared"
|
2023-02-14 18:22:28 +00:00
|
|
|
mpc add "$play_link" 1>/dev/null
|
|
|
|
mpc play 1>/dev/null
|
2023-05-08 22:23:01 +00:00
|
|
|
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
|