Add support for piping a playlist in through STDIN
This commit is contained in:
		
							
								
								
									
										12
									
								
								ptgdp
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								ptgdp
									
									
									
									
									
								
							@@ -290,13 +290,8 @@ playlist() {
 | 
			
		||||
	local -i totallines=0
 | 
			
		||||
	while read line; do
 | 
			
		||||
		totallines+=1
 | 
			
		||||
		validateline "$line" || continue
 | 
			
		||||
		goodlines+=1
 | 
			
		||||
	done < "$1"
 | 
			
		||||
	log "Parsed playlist \"$1\" with $goodlines songs"
 | 
			
		||||
	log "Playlist has $totallines total lines" 2
 | 
			
		||||
	while read line; do
 | 
			
		||||
		if validateline "$line"; then
 | 
			
		||||
			goodlines+=1
 | 
			
		||||
			queuesong "$line" || error "Failed to enqueue song: \"$line\""
 | 
			
		||||
			case $_returnstatus in
 | 
			
		||||
				dl)
 | 
			
		||||
@@ -321,6 +316,7 @@ playlist() {
 | 
			
		||||
		backend-execqueue
 | 
			
		||||
	fi
 | 
			
		||||
	log "Finished: $dlcache cached, $dlsuccess downloaded, $dlerr failed"
 | 
			
		||||
	log "Playlist has $totallines total lines, $goodlines of them songs" 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Main
 | 
			
		||||
@@ -404,9 +400,13 @@ main() {
 | 
			
		||||
		error "Failed to find program: $_return" 1
 | 
			
		||||
	fi
 | 
			
		||||
	if [ -n "${_args[*]}" ]; then
 | 
			
		||||
		# Files specified on the command line have priority
 | 
			
		||||
		for arg in "${_args[@]}"; do
 | 
			
		||||
			playlist "$arg"
 | 
			
		||||
		done
 | 
			
		||||
	elif ! [ -t 0 ]; then
 | 
			
		||||
		# If there are none of those, read from STDIN
 | 
			
		||||
		playlist "/dev/stdin"
 | 
			
		||||
	else
 | 
			
		||||
		warn "Nothing to do"
 | 
			
		||||
		exit 0
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user