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

9
jptgdp
View File

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