dotfiles

<-- duh.
git clone https://hhvn.uk/dotfiles
git clone git://hhvn.uk/dotfiles
Log | Files | Refs | Submodules | LICENSE

get (803B)


      1 #!/bin/rc
      2 
      3 fn usage {
      4 	printf 'usage: tag/get files...\n' >[1=2]
      5 	exit 2
      6 }
      7 
      8 if (~ $#* 0 || ~ $1 -h) {
      9 	usage
     10 }
     11 
     12 label = ''
     13 
     14 for (f in $*) {
     15 	if (!~ $#* 1) {
     16 		label = '[' ^ $f ^ '] '
     17 	}
     18 	if (!test -f $f) {
     19 		printf '%sCould not locate file.\n' $label >[1=2]
     20 		continue
     21 	}
     22 
     23 	if (~ $f *.opus) {
     24 		eargs = (-map_metadata 0:s:a:0)
     25 	} else {
     26 		eargs = ()
     27 	}
     28 
     29 	ffmpeg -i $f $eargs -f ffmetadata - >[2]/dev/null |
     30 		awk -vlabel=^$label '/=/ {
     31 			key = $0;  sub(/=.*/, "", key)
     32 			pad = key; gsub(/./, " ", pad)
     33 			val = $0;  sub(/^[^=]*=/, "", val)
     34 			printf("%s%s: %s\n", label, key, val);
     35 			next
     36 		}
     37 
     38 		# Print multiline metadata values indented
     39 		/^[^;\[]/ { printf("%s%s  %s\n", label, pad, $0) }
     40 
     41 		# Chapters/streams
     42 		/^\[/ { printf("\n%s%s\n", label, $0) }' |
     43 		sed -E 's/\\$//g;s/\\([=;#\\])/\1/g'
     44 }