More log changes, add download-only option
This commit is contained in:
		@@ -4,13 +4,13 @@ A tool to play a plaintext playlist composed entirely of youtube-dl search queri
 | 
			
		||||
 | 
			
		||||
## 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
 | 
			
		||||
 | 
			
		||||
Make a file containing a few download queries. For example:
 | 
			
		||||
 | 
			
		||||
    myplaylist.gdp
 | 
			
		||||
    myplaylist
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
alice in chains love hate love
 | 
			
		||||
@@ -20,7 +20,7 @@ tool parabola
 | 
			
		||||
 | 
			
		||||
Then invoke `ptgdp`:
 | 
			
		||||
 | 
			
		||||
    ptgdp myplaylist.gdp
 | 
			
		||||
    ptgdp myplaylist
 | 
			
		||||
 | 
			
		||||
See below for more intricate usage.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										19
									
								
								ptgdp
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								ptgdp
									
									
									
									
									
								
							@@ -25,6 +25,7 @@ declare -A _config=(
 | 
			
		||||
)
 | 
			
		||||
declare _optconfigfile="${XDG_CONFIG_HOME:-$HOME/.config}/${_name}.conf"
 | 
			
		||||
declare -i _optautoplay=0
 | 
			
		||||
declare -i _optdlonly
 | 
			
		||||
declare -i _opthelp
 | 
			
		||||
declare -i _optverbose
 | 
			
		||||
# Working variables
 | 
			
		||||
@@ -226,12 +227,14 @@ backend-execqueue() {
 | 
			
		||||
			fi
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
	if [ -z "$_optdlonly" ]; then
 | 
			
		||||
		for song in "${_queue[@]}"; do
 | 
			
		||||
			backend-enqueue "$song"
 | 
			
		||||
		done
 | 
			
		||||
		if [ "$_optautoplay" != "0" ]; then
 | 
			
		||||
			backend-play
 | 
			
		||||
		fi
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Core program functions
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
  -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
 | 
			
		||||
  -p			Play the queue after it's built
 | 
			
		||||
  -v			Print more status messages. Stacks
 | 
			
		||||
@@ -288,11 +292,14 @@ playlist() {
 | 
			
		||||
# Main
 | 
			
		||||
main() {
 | 
			
		||||
	# Getopts before anything else
 | 
			
		||||
	while getopts ":c:hpv" opt; do
 | 
			
		||||
	while getopts ":c:dhpv" opt; do
 | 
			
		||||
		case $opt in
 | 
			
		||||
			c)
 | 
			
		||||
				_optconfigfile="$OPTARG"
 | 
			
		||||
				;;
 | 
			
		||||
			d)
 | 
			
		||||
				_optdlonly=1
 | 
			
		||||
				;;
 | 
			
		||||
			h)
 | 
			
		||||
				_opthelp=1
 | 
			
		||||
				;;
 | 
			
		||||
@@ -322,6 +329,8 @@ main() {
 | 
			
		||||
				log "Setting $varname to $value" 2
 | 
			
		||||
			fi
 | 
			
		||||
		done < "$_optconfigfile"
 | 
			
		||||
	else
 | 
			
		||||
		warn "Could not find configuration file" 2
 | 
			
		||||
	fi
 | 
			
		||||
	# Store arguments
 | 
			
		||||
	shift $((OPTIND - 1))
 | 
			
		||||
@@ -344,7 +353,7 @@ main() {
 | 
			
		||||
				error "Missing dependency for backend ${_config[backend]}: $_return" 50
 | 
			
		||||
				;;
 | 
			
		||||
			*)
 | 
			
		||||
				error "Dependency error: $errorcode: $_return" 50
 | 
			
		||||
				error "Backend error: $errorcode: $_return" 50
 | 
			
		||||
				;;
 | 
			
		||||
		esac
 | 
			
		||||
	fi
 | 
			
		||||
@@ -354,15 +363,15 @@ main() {
 | 
			
		||||
 | 
			
		||||
	# Do the do
 | 
			
		||||
	log "Validating dependencies" 2
 | 
			
		||||
	if ! has youtube-dl; then
 | 
			
		||||
		error "Failed to validate dependency on program: $_return" 1
 | 
			
		||||
	if ! has youtube-dl pgrep; then
 | 
			
		||||
		error "Failed to find program: $_return" 1
 | 
			
		||||
	fi
 | 
			
		||||
	if [ -n "${_args[*]}" ]; then
 | 
			
		||||
		for arg in "${_args[@]}"; do
 | 
			
		||||
			playlist "$arg"
 | 
			
		||||
		done
 | 
			
		||||
	else
 | 
			
		||||
		log "Nothing to do"
 | 
			
		||||
		warn "Nothing to do"
 | 
			
		||||
		exit 0
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user