-
Notifications
You must be signed in to change notification settings - Fork 0
/
flactomp3
executable file
·39 lines (38 loc) · 939 Bytes
/
flactomp3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
# vi:et lbr noet sw=2 ts=2 tw=79 wrap
# Copyright 2019-2024 David Rabkin
# shellcheck disable=SC1091,SC2034 # File not following, variable unused.
readonly \
BASE_APP_VERSION=0.9.20240831 \
BASE_MIN_VERSION=0.9.20240831
. base.sh
[ "$#" -eq 1 ] || die flactomp3: try flactomp3 [file name]
readonly \
SRC="$1" \
TAG="$BASE_WIP"/tags
isreadable "$SRC" || die "$SRC" is not readable.
DST="$(printf %s "$SRC" | sed 's/\.flac/.mp3/')"
readonly DST
should_continue "Convert $SRC to $DST" || cya
metaflac --export-tags-to=/dev/stdout "$SRC" |
sed \
-e 's/=/="/' \
-e 's/$/"/' \
-e 's/Album=/ALBUM=/' \
-e 's/Genre=/GENRE=/' \
-e 's/Artist=/ARTIST=/' >"$TAG"
cat "$TAG"
# shellcheck source=/dev/null
. "$TAG"
rm "$TAG"
flac -dc "$SRC" |
lame \
-b 320 \
-h \
--ta "${ARTIST}" \
--tg "${GENRE}" \
--tl "${ALBUM}" \
--tn "${TRACKNUMBER}" \
--tt "${TITLE}" \
--ty "${DATE}" \
--add-id3v2 /dev/stdin "$DST"