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:
24
ptgdp
24
ptgdp
@@ -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)"
|
_tmpfile="$_tmpdir/tmpfile-$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 12)"
|
||||||
_xdguserdirs="${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs"
|
_xdguserdirs="${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs"
|
||||||
[ -f "$_xdguserdirs" ] && source "$_xdguserdirs"
|
[ -f "$_xdguserdirs" ] && source "$_xdguserdirs"
|
||||||
_musicdir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name"
|
_musicdir="${XDG_MUSIC_DIR:-$HOME/Music}/${PTGDP_MUSIC_DIR:PTGDP Songs}"
|
||||||
_musiclink="${XDG_MUSIC_DIR:-$HOME/Music}/PTGDP Songs"
|
|
||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
log() {
|
log() {
|
||||||
@@ -102,6 +101,13 @@ files are cached in your Music folder under "PTGDP Songs" for offline use.
|
|||||||
|
|
||||||
-h Print this help text
|
-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
|
Copyright (c) 2019 rehashedsalt@cock.li
|
||||||
Licensed under the MIT license
|
Licensed under the MIT license
|
||||||
EOF
|
EOF
|
||||||
@@ -135,15 +141,6 @@ playlist() {
|
|||||||
[ -e "$1" ] || error "Playlist \"$1\" does not exist" 50
|
[ -e "$1" ] || error "Playlist \"$1\" does not exist" 50
|
||||||
[ -f "$1" ] || error "Playlist \"$1\" is not a file" 50
|
[ -f "$1" ] || error "Playlist \"$1\" is not a file" 50
|
||||||
[ -r "$1" ] || error "Cannot read playlist \"$1\"" 51
|
[ -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
|
if [ -z "$_optdownloadonly" ] && ! mpc status > /dev/null 2>&1; then
|
||||||
notify "Could not communicate with MPD" \
|
notify "Could not communicate with MPD" \
|
||||||
"MPD connection was refused. Ensure your configuration is correct and the daemon is currently running." \
|
"MPD connection was refused. Ensure your configuration is correct and the daemon is currently running." \
|
||||||
@@ -189,9 +186,10 @@ playlist() {
|
|||||||
dlexist+=1
|
dlexist+=1
|
||||||
fi
|
fi
|
||||||
validatedeps mpc || continue
|
validatedeps mpc || continue
|
||||||
[ -z "$_optdownloadonly" ] && mpc add "$filename"
|
[ -z "$_optdownloadonly" ] || continue
|
||||||
|
mpc add "$filename"
|
||||||
if [ -n "$_optautoplay" ]; then
|
if [ -n "$_optautoplay" ]; then
|
||||||
mpc play
|
mpc play > /dev/null 2>&1
|
||||||
unset _optautoplay
|
unset _optautoplay
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user