Skip to content

Commit 07b659e

Browse files
committed
Keep cover art
1 parent 7f0200a commit 07b659e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

reflac

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ recompress()
6060
fi
6161

6262
if [ $NOACTION -eq 0 ]; then
63+
HAS_COVER_ART=1
6364
metaflac --no-utf8-convert \
6465
--export-tags-to="$TMPDIR/$(basename -s flac -- "$flac")tag" \
6566
-- "$flac"
66-
67+
metaflac --export-picture-to="$TMPDIR/$(basename -s flac -- "$flac")img" \
68+
-- "$flac" > /dev/null 2>&1 || HAS_COVER_ART=0 #the error is handled later. do not exit the script
6769
if [ $VERBOSE -gt 1 ]; then
6870
flac --force-rf64-format --output-prefix="$TMPDIR/" -d -- "$flac"
6971
flac --delete-input-file -$FLAC_LEVEL -- \
@@ -74,9 +76,16 @@ recompress()
7476
"$TMPDIR/$(basename -s flac -- "$flac")rf64"
7577
fi
7678

77-
metaflac --no-utf8-convert $PRESERVE_MODTIME \
78-
--import-tags-from="$TMPDIR/$(basename -s flac -- "$flac")tag" \
79-
-- "$TMPDIR/$flac"
79+
if [ $HAS_COVER_ART -eq 1 ]; then
80+
metaflac --no-utf8-convert $PRESERVE_MODTIME \
81+
--import-tags-from="$TMPDIR/$(basename -s flac -- "$flac")tag" \
82+
--import-picture-from="$TMPDIR/$(basename -s flac -- "$flac")img" \
83+
-- "$TMPDIR/$flac"
84+
else
85+
metaflac --no-utf8-convert $PRESERVE_MODTIME \
86+
--import-tags-from="$TMPDIR/$(basename -s flac -- "$flac")tag" \
87+
-- "$TMPDIR/$flac"
88+
fi
8089
mv -f -- "$TMPDIR/$flac" "$flac.new"
8190
if [ $SYNC -eq 1 ]; then
8291
sync "$flac.new"
@@ -86,6 +95,9 @@ recompress()
8695
mv -f "$flac.new" "$flac"
8796
fi
8897
rm -f -- "$TMPDIR/$(basename -s flac -- "$flac")tag"
98+
if [ $HAS_COVER_ART -eq 1 ]; then
99+
rm -f -- "$TMPDIR/$(basename -s flac -- "$flac")img"
100+
fi
89101
fi
90102
done
91103
}

0 commit comments

Comments
 (0)