dotfiles

personal dotfiles
git clone anongit@rnpnr.xyz:dotfiles.git
Log | Files | Refs | Feed | Submodules

tag (1625B)


      1 #!/bin/sh
      2 
      3 usage() {
      4 	echo \
      5 "usage: tag [args] file
      6 args:
      7 	-A album
      8 	-C composer
      9 	-D disc number
     10 	-a artist
     11 	-c comment
     12 	-d date
     13 	-g genre
     14 	-i interactive mode
     15 	-p performer
     16 	-q album artist
     17 	-s title
     18 	-t track number
     19 Only title is required."
     20 
     21 	exit 1
     22 }
     23 
     24 while getopts "A:C:D:a:b:c:d:g:p:s:t:i" arg; do
     25 	case "${arg}" in
     26 	A) album="${OPTARG}" ;;
     27 	C) composer="${OPTARG}" ;;
     28 	D) disc_num="${OPTARG}" ;;
     29 	a) artist="${OPTARG}" ;;
     30 	b) album_artist="${OPTARG}" ;;
     31 	c) comment="${OPTARG}" ;;
     32 	d) date="${OPTARG}" ;;
     33 	g) genre="${OPTARG}" ;;
     34 	i) int=1 ;;
     35 	p) performer="${OPTARG}" ;;
     36 	s) title="${OPTARG}" ;;
     37 	t) track_num="${OPTARG}" ;;
     38 	*) usage ;;
     39 	esac
     40 done; shift $((OPTIND - 1))
     41 
     42 file="$1"
     43 [ ! -f "$file" ] && echo "invalid file" && usage
     44 
     45 [ $int ] && for i in \
     46 album album_artist artist comment composer date disc_num genre \
     47 performer title track_num; do
     48 	# hacky, hacky, hacky :^)
     49 	[ -z $(eval echo "\$$i") ] && printf "$i: " && read -r $i
     50 done
     51 [ -z "$title" ] && usage
     52 
     53 case "$file" in
     54 *.mp3) eyeD3 -Q --non-std-genres \
     55 	--composer "$composer" \
     56 	-A "$album" \
     57 	-G "$genre" \
     58 	-Y "$date" \
     59 	-a "$artist" \
     60 	-b "$album_artist" \
     61 	-c "$comment" \
     62 	-d "$disc_num" \
     63 	-n "$track_num" \
     64 	-t "$title" \
     65 	"$file" ;;
     66 
     67 *.flac) tool="metaflac --remove-all-tags --import-tags-from=-" ;;
     68 *.ogg) tool="vorbiscomment -w" ;;
     69 *.opus) tool="opustags -Si" ;;
     70 *) echo "filetype not implemented" ;;
     71 esac
     72 
     73 [ "$tool" ] && echo "ALBUM=$album
     74 ALBUMARTIST=$album_artist
     75 ARTIST=$artist
     76 COMPOSER=$composer
     77 DATE=$date
     78 DESCRITION=$comment
     79 DISCNUMBER=$disc_num
     80 GENRE=$genre
     81 PERFORMER=$performer
     82 TITLE=$title
     83 TRACKNUMBER=$track_num" | $tool "$file"