37 lines
524 B
Bash
Executable File
37 lines
524 B
Bash
Executable File
#!/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
|
|
|
|
echo "Clear playlist? (N/y)"
|
|
read -r clearplay
|
|
|
|
case "$clearplay" in
|
|
"y")
|
|
mpc clear 1>/dev/null
|
|
echo "Playlist cleared"
|
|
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
|
|
|
|
exit 0
|