Skip to content

Instantly share code, notes, and snippets.

@Senorsen
Last active April 26, 2017 07:38
Show Gist options
  • Save Senorsen/7afb0ccc18a5e4401f57131540a21ed0 to your computer and use it in GitHub Desktop.
Save Senorsen/7afb0ccc18a5e4401f57131540a21ed0 to your computer and use it in GitHub Desktop.
Generate common flac file with 'fLaC' header (use flac package), so firefox or other softwares will support the file
#!/bin/sh
set -e
flac 2>&1 >/dev/null || (echo "Install flac package first. "; exit 1)
FILE=$1
# get the tags
ARTIST=$(metaflac "$FILE" --show-tag=ARTIST | sed s/.*=//g || true)
TITLE=$(metaflac "$FILE" --show-tag=TITLE | sed s/.*=//g || true)
ALBUM=$(metaflac "$FILE" --show-tag=ALBUM | sed s/.*=//g || true)
echo "Music Info: $ARTIST - $TITLE"
flac -d "${FILE}" -o "${FILE}.riff" -f
flac -o -8 "${FILE}.riff" -o "${FILE}_new.flac" -f
cat<<EOF | metaflac --no-utf8-convert --remove-all-tags --import-tags-from=- "${FILE}_new.flac"
ARTIST=$ARTIST
TITLE=$TITLE
ALBUM=$ALBUM
EOF
echo "Finished. "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment