closes #1
This commit is contained in:
		
							parent
							
								
									072eb15aaa
								
							
						
					
					
						commit
						bf3da17482
					
				
							
								
								
									
										36
									
								
								yt
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								yt
									
									
									
									
									
								
							@ -18,6 +18,15 @@
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
test -z "$DEBUG" || set -x
 | 
			
		||||
 | 
			
		||||
argv0="$0"
 | 
			
		||||
com="$1"
 | 
			
		||||
 | 
			
		||||
cachefile="$XDG_CACHE_HOME/yt.cache"
 | 
			
		||||
FMT='%(title)s – %(channel)s (%(duration>%H:%M:%S)s) [%(webpage_url)s]'
 | 
			
		||||
WBAPI='https://archive.org/wayback/available?url='
 | 
			
		||||
 | 
			
		||||
add() { # adds a video to a playlist file
 | 
			
		||||
	while test -n "$2"; do
 | 
			
		||||
		if test -n "$(grep -e "$1" "$2")"
 | 
			
		||||
@ -56,6 +65,12 @@ archive() { # archives a video to the Wayback Machine
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cache() { # cache the video title for faster retrieval
 | 
			
		||||
	if test -z "$XDG_CACHE_HOME"; then
 | 
			
		||||
		printf "%s: unable to create title cachefile: \$XDG_CACHE_HOME unset." \
 | 
			
		||||
			"$argv0" 2>&1
 | 
			
		||||
		exit 69 # sysexits.h(3) EX_UNAVAILABLE
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	while test -n "$1"; do
 | 
			
		||||
		grep "$1" "$cachefile" 2>/dev/null 1>&2 || printf '%s\n' \
 | 
			
		||||
			"$(yt-dlp -s "$1" --print "$FMT")" >>"$cachefile"
 | 
			
		||||
@ -85,6 +100,11 @@ music() { # downloads a video, splitting by chapter and only saving the audio
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pick() { # Pick a video to play from a list of videos
 | 
			
		||||
	if test -z "$YTPICK"; then
 | 
			
		||||
		printf "%s: Please set \$YTPICK to your preferred picking tool." "$argv0" 1>&2
 | 
			
		||||
		exit 78 # sysexits.h(3) EX_CONFIG
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	while test -n "$1"; do
 | 
			
		||||
		for line in $(lines "$1"); do
 | 
			
		||||
			if test -n "$(printf '%s\n' "$line" | sed -n '/^\#/p')"
 | 
			
		||||
@ -165,22 +185,6 @@ verify() { # replaces videos with archived versions if they are not available
 | 
			
		||||
	done
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
argv0="$0"
 | 
			
		||||
com="$1"
 | 
			
		||||
 | 
			
		||||
cachefile="$XDG_CACHE_HOME/yt.cache"
 | 
			
		||||
FMT='%(title)s – %(channel)s (%(duration>%H:%M:%S)s) [%(webpage_url)s]'
 | 
			
		||||
WBAPI='https://archive.org/wayback/available?url='
 | 
			
		||||
 | 
			
		||||
if test -z "$YTPICK"; then
 | 
			
		||||
	printf "%s: Please set \$YTPICK to your preferred picking tool." "$argv0" 1>&2
 | 
			
		||||
	exit 78 # sysexits.h(3) EX_CONFIG
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if test -n "$DEBUG"; then
 | 
			
		||||
	set -x
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
for dep in \
 | 
			
		||||
	curl \
 | 
			
		||||
	jq \
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user