jptgdp: Rename variable, reorganize help text

This commit is contained in:
Salt 2019-06-13 07:58:48 -05:00
parent fe4b526eac
commit 0f4ebd81cc

15
jptgdp
View File

@ -12,7 +12,7 @@ _tmpdir="${XDG_CACHE_HOME:-$HOME/.cache}/$_name"
_tmpfile="$_tmpdir/tmpfile" _tmpfile="$_tmpdir/tmpfile"
_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"
_playlistdir="${XDG_MUSIC_DIR:-$HOME/Music}/JPTGDP Songs" _musicdir="${XDG_MUSIC_DIR:-$HOME/Music}/JPTGDP Songs"
# Helper functions # Helper functions
log() { log() {
@ -45,7 +45,7 @@ trapexit() {
# Critical functions # Critical functions
clearcache() { clearcache() {
[ -n "$_playlistdir" ] && rm "$_playlistdir"/* > /dev/null 2>&1 [ -n "$_musicdir" ] && rm "$_musicdir"/* > /dev/null 2>&1
log "Cache has been emptied" log "Cache has been emptied"
} }
helptext() { helptext() {
@ -53,12 +53,15 @@ helptext() {
Usage: $_name [OPTION] Usage: $_name [OPTION]
Use youtube-dl and audacious to queue up a playlist given a file of only search Use youtube-dl and audacious to queue up a playlist given a file of only search
queries. queries.
-f <file> The playlist file to load
-c Clears the cache (which can become quite large) -c Clears the cache (which can become quite large)
-d Download only; don't queue anything up -d Download only; don't queue anything up
-f <file> The playlist file to load -s Shuffle the playlist
-r <directory> Start up rofi, if installed, and present a listing of -r <directory> Start up rofi, if installed, and present a listing of
all .ytp files in the given directory all .ytp files in the given directory
-s Shuffle the playlist
-h Print this help text -h Print this help text
Copyright (c) 2019 rehashedsalt@cock.li Copyright (c) 2019 rehashedsalt@cock.li
@ -77,7 +80,7 @@ playlist() {
while read line; do while read line; do
[ -z "$line" ] && continue [ -z "$line" ] && continue
rm "$_tmpfile"* > /dev/null 2>&1 rm "$_tmpfile"* > /dev/null 2>&1
filename="$_playlistdir/${line//[^ a-zA-Z0-9\[\]|()_-]/}" filename="$_musicdir/${line//[^ a-zA-Z0-9\[\]|()_-]/}"
if ! [ -f "$filename" ]; then if ! [ -f "$filename" ]; then
log "Finding a song for \"$line\"" log "Finding a song for \"$line\""
youtube-dl \ youtube-dl \
@ -109,7 +112,7 @@ main() {
# Boostrapping and setup # Boostrapping and setup
validatedeps basename mktemp || error "Critical dependency $_return was not met" 1 validatedeps basename mktemp || error "Critical dependency $_return was not met" 1
mkdir -p "$_tmpdir" mkdir -p "$_tmpdir"
mkdir -p "$_playlistdir" mkdir -p "$_musicdir"
trap trapexit EXIT trap trapexit EXIT
# Actual program stuff # Actual program stuff