ptgdp: Switch from a symlink to just directly downloading the music

You can, of course, link this thing back out if you want to
This commit is contained in:
Salt 2019-08-13 03:47:37 -05:00
parent ac2043ecb6
commit dc0fc3f317

24
ptgdp
View File

@ -16,8 +16,7 @@ _tmpdir="${XDG_CACHE_HOME:-$HOME/.cache}/$_name"
_tmpfile="$_tmpdir/tmpfile-$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 12)"
_xdguserdirs="${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs"
[ -f "$_xdguserdirs" ] && source "$_xdguserdirs"
_musicdir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name"
_musiclink="${XDG_MUSIC_DIR:-$HOME/Music}/PTGDP Songs"
_musicdir="${XDG_MUSIC_DIR:-$HOME/Music}/${PTGDP_MUSIC_DIR:PTGDP Songs}"
# Helper functions
log() {
@ -102,6 +101,13 @@ files are cached in your Music folder under "PTGDP Songs" for offline use.
-h Print this help text
Environment Variables
In addition to XDG-spec variables (XDG_CACHE_HOME, user-dirs.dirs, etc.), ptgdp
also respects an additional variable:
PTGDP_MUSIC_DIR The subdirectory in XDG_MUSIC_DIR to save music to
Copyright (c) 2019 rehashedsalt@cock.li
Licensed under the MIT license
EOF
@ -135,15 +141,6 @@ playlist() {
[ -e "$1" ] || error "Playlist \"$1\" does not exist" 50
[ -f "$1" ] || error "Playlist \"$1\" is not a file" 50
[ -r "$1" ] || error "Cannot read playlist \"$1\"" 51
if ! [ -f "$_musicdir/.symlink" ]; then
if ln -s "$_musicdir" "$_musiclink" > /dev/null 2>&1; then
log "Made symlink to music directory"
touch "$_musicdir/.symlink"
else
error "Failed to make symlink to music directory"
log "Music can be found at \"$_musicdir\""
fi
fi
if [ -z "$_optdownloadonly" ] && ! mpc status > /dev/null 2>&1; then
notify "Could not communicate with MPD" \
"MPD connection was refused. Ensure your configuration is correct and the daemon is currently running." \
@ -189,9 +186,10 @@ playlist() {
dlexist+=1
fi
validatedeps mpc || continue
[ -z "$_optdownloadonly" ] && mpc add "$filename"
[ -z "$_optdownloadonly" ] || continue
mpc add "$filename"
if [ -n "$_optautoplay" ]; then
mpc play
mpc play > /dev/null 2>&1
unset _optautoplay
fi
else