flactools

package module
v0.0.0-...-61af98d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

README

flactools

Go-based tools for FLAC music collection maintenance

This repository contains tools I use to manage FLAC music files on my Synology NAS.

Each utility should have a --help option. Check the source of each program for additional information that would be in the man page if Synology boxes had man pages.

flaccat and flacdiff

The first two utilities are flaccat and flacdiff. Used together, they offer a way to check your music library for additions, deletions, and file moves.

The flaccat utility scans the specified directory structure and outputs a list of FLAC files along with their content hashes. The flacdiff utility compares two such listings, and works out which files have been added, which have been moved, and which have been removed.

% flaccat /volume1/FLAC > ~/flaclist.old
[ some weeks later ]
% flaccat /volume1/FLAC > ~/flaclist.new
% flacdiff ~/flaclist.old ~/flaclist.new > report.txt

flacsum

The third utility is flacsum, which checks the actual data of the FLAC files against the MD5 checksums stored inside, to test for file corruption. It's very slow, so you probably won't want to run it very often.

flacname and flacmv

The next two utilities are for cleaning up naming of files. The way they work is based on my observation that you can basically count on files in the same directory belonging together as a unit, but that their names may be a mess, and the directory layout may be a mess. Hence, one utility handles naming and moving folders only, one handles naming files only, and they never change which folder a file is in.

The folder namer is flacmv, which uses FLAC metadata to move folders around based on artist and album name, putting them under Artist/Album. It can also attempt to write out a shell script to perform the moves, so you can examine what it suggests before doing it. (However, if you have really awkward characters in your folder names, you'll have to fix up the shell quoting yourself.) It also cleans up the directory names to have no spaces or punctuation in, but it allows accented letters.

Example:

flacmv -dest /home/me/music *.flac

The fifth is flacname, which changes the names of FLAC files to be discnumber-tracknumber-title.flac, with the same filename cleanup rules as flacmv -- but doesn't move the files between directories. Again, it can either perform the renaming for you, or output a shell script.

Installation

Quick install:

go install codeberg.org/meta/flactools/cmd/flaccat@latest
go install codeberg.org/meta/flactools/cmd/flacdiff@latest
go install codeberg.org/meta/flactools/cmd/flaclist@latest
go install codeberg.org/meta/flactools/cmd/flacmv@latest
go install codeberg.org/meta/flactools/cmd/flacname@latest
go install codeberg.org/meta/flactools/cmd/flacsum@latest

Or check out the repository and run build.sh.

Because the utilities are all written in pure Go, and use only pure Go libraries, it should be easy to cross-compile them for any Synology box, whether it's Intel-based or ARM-based.

For example, to build a 64-bit ARM binary of flaccat:

cd cmd/flaccat
GOOS=linux GOARCH=arm64 go build

Or to build a binary for an Intel-based Synology box on my Mac:

cd cmd/flaccat
GOOS=linux GOARCH=amd64 go build

Bugs and limitations

For flacdiff, the entire list of FLAC files and their MD5 checksums must fit into RAM. That hasn't been a problem for me yet, and I have 37,000 tracks. If it becomes a problem I may look at using some sort of database, but for now the performance of doing it all in RAM is too good to pass up.

Credits

The heavy lifting is performed by https://github.com/mewkiz/flac

I took some Ruby scripts I had been using on my old Linux box, and rewrote them in Go using the above library, so that I could easily build binaries for my Syno box and get native code performance.

License

GPL v3.

Contact

mathew meta@pobox.com

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanName

func CleanName(x string) string

func Coalesce

func Coalesce(args ...string) string

func GetTags

func GetTags(fname string) (map[string]string, error)

func GetVorbisComment

func GetVorbisComment(fname string) (*meta.VorbisComment, error)

func TagMap

func TagMap(vc *meta.VorbisComment) map[string]string

Types

This section is empty.

Directories

Path Synopsis
cmd
flaccat
flaccat
flaccat
flaclist
flaccat
flaccat
flacsum
flacsum
flacsum

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL