More log changes, add download-only option
This commit is contained in:
parent
3104291005
commit
6c71a0bb94
@ -4,13 +4,13 @@ A tool to play a plaintext playlist composed entirely of youtube-dl search queri
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Put `ptgdp` somewhere in `$PATH` and install `youtube-dl`.
|
Put `ptgdp` somewhere in `$PATH` and install youtube-dl. Additionally, you need some implementation of `pgrep`, which is probably already on your system, and Bash.
|
||||||
|
|
||||||
## Quickstart
|
## Quickstart
|
||||||
|
|
||||||
Make a file containing a few download queries. For example:
|
Make a file containing a few download queries. For example:
|
||||||
|
|
||||||
myplaylist.gdp
|
myplaylist
|
||||||
|
|
||||||
```
|
```
|
||||||
alice in chains love hate love
|
alice in chains love hate love
|
||||||
@ -20,7 +20,7 @@ tool parabola
|
|||||||
|
|
||||||
Then invoke `ptgdp`:
|
Then invoke `ptgdp`:
|
||||||
|
|
||||||
ptgdp myplaylist.gdp
|
ptgdp myplaylist
|
||||||
|
|
||||||
See below for more intricate usage.
|
See below for more intricate usage.
|
||||||
|
|
||||||
|
29
ptgdp
29
ptgdp
@ -25,6 +25,7 @@ declare -A _config=(
|
|||||||
)
|
)
|
||||||
declare _optconfigfile="${XDG_CONFIG_HOME:-$HOME/.config}/${_name}.conf"
|
declare _optconfigfile="${XDG_CONFIG_HOME:-$HOME/.config}/${_name}.conf"
|
||||||
declare -i _optautoplay=0
|
declare -i _optautoplay=0
|
||||||
|
declare -i _optdlonly
|
||||||
declare -i _opthelp
|
declare -i _opthelp
|
||||||
declare -i _optverbose
|
declare -i _optverbose
|
||||||
# Working variables
|
# Working variables
|
||||||
@ -226,11 +227,13 @@ backend-execqueue() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
for song in "${_queue[@]}"; do
|
if [ -z "$_optdlonly" ]; then
|
||||||
backend-enqueue "$song"
|
for song in "${_queue[@]}"; do
|
||||||
done
|
backend-enqueue "$song"
|
||||||
if [ "$_optautoplay" != "0" ]; then
|
done
|
||||||
backend-play
|
if [ "$_optautoplay" != "0" ]; then
|
||||||
|
backend-play
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,6 +245,7 @@ Use youtube-dl and a music player to queue up or download a number of songs
|
|||||||
given plaintext files with only search queries
|
given plaintext files with only search queries
|
||||||
|
|
||||||
-c [FILE] Load the given file in place of the usual config file
|
-c [FILE] Load the given file in place of the usual config file
|
||||||
|
-d Download songs but don't queue them up
|
||||||
-h Print this help text
|
-h Print this help text
|
||||||
-p Play the queue after it's built
|
-p Play the queue after it's built
|
||||||
-v Print more status messages. Stacks
|
-v Print more status messages. Stacks
|
||||||
@ -288,11 +292,14 @@ playlist() {
|
|||||||
# Main
|
# Main
|
||||||
main() {
|
main() {
|
||||||
# Getopts before anything else
|
# Getopts before anything else
|
||||||
while getopts ":c:hpv" opt; do
|
while getopts ":c:dhpv" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
c)
|
c)
|
||||||
_optconfigfile="$OPTARG"
|
_optconfigfile="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
d)
|
||||||
|
_optdlonly=1
|
||||||
|
;;
|
||||||
h)
|
h)
|
||||||
_opthelp=1
|
_opthelp=1
|
||||||
;;
|
;;
|
||||||
@ -322,6 +329,8 @@ main() {
|
|||||||
log "Setting $varname to $value" 2
|
log "Setting $varname to $value" 2
|
||||||
fi
|
fi
|
||||||
done < "$_optconfigfile"
|
done < "$_optconfigfile"
|
||||||
|
else
|
||||||
|
warn "Could not find configuration file" 2
|
||||||
fi
|
fi
|
||||||
# Store arguments
|
# Store arguments
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
@ -344,7 +353,7 @@ main() {
|
|||||||
error "Missing dependency for backend ${_config[backend]}: $_return" 50
|
error "Missing dependency for backend ${_config[backend]}: $_return" 50
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
error "Dependency error: $errorcode: $_return" 50
|
error "Backend error: $errorcode: $_return" 50
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
@ -354,15 +363,15 @@ main() {
|
|||||||
|
|
||||||
# Do the do
|
# Do the do
|
||||||
log "Validating dependencies" 2
|
log "Validating dependencies" 2
|
||||||
if ! has youtube-dl; then
|
if ! has youtube-dl pgrep; then
|
||||||
error "Failed to validate dependency on program: $_return" 1
|
error "Failed to find program: $_return" 1
|
||||||
fi
|
fi
|
||||||
if [ -n "${_args[*]}" ]; then
|
if [ -n "${_args[*]}" ]; then
|
||||||
for arg in "${_args[@]}"; do
|
for arg in "${_args[@]}"; do
|
||||||
playlist "$arg"
|
playlist "$arg"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
log "Nothing to do"
|
warn "Nothing to do"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user