jptgdp: Add error handling, move music dir to Music

This commit is contained in:
Salt 2019-06-13 07:50:58 -05:00
parent 81c4dfa992
commit fe4b526eac

11
jptgdp
View File

@ -10,7 +10,9 @@
_name="$(basename -- "$0")"
_tmpdir="${XDG_CACHE_HOME:-$HOME/.cache}/$_name"
_tmpfile="$_tmpdir/tmpfile"
_playlistdir="$_tmpdir"/playlist
_xdguserdirs="${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs"
[ -f "$_xdguserdirs" ] && source "$_xdguserdirs"
_playlistdir="${XDG_MUSIC_DIR:-$HOME/Music}/JPTGDP Songs"
# Helper functions
log() {
@ -87,8 +89,11 @@ playlist() {
-o "$_tmpfile.%(ext)s" \
ytsearch:"$line" \
> /dev/null 2>&1 &
wait
mv "$_tmpfile"* "$filename"
if wait $!; then
mv "$_tmpfile"* "$filename"
else
log "No results found for \"$line\""
fi
fi
[ -z "$_optdownloadonly" ] && audacious -e "$filename"
done < <(if [ -n "$_optshuffle" ]; then shuf "$1"; else cat "$1"; fi)