Tree


.build.ymlcommits | blame
.gitignorecommits | blame
Cargo.lockcommits | blame
Cargo.tomlcommits | blame
LICENSEcommits | blame
README.mdcommits | blame
flake.lockcommits | blame
flake.nixcommits | blame
hack/
prek.tomlcommits | blame
src/

README.md

# hakuna

A command-line tool that fetches music metadata (genres and labels) from Discogs or MusicBrainz and writes them to audio files.

## Features

* Fetch metadata (genres, labels) from Discogs or MusicBrainz
* Write metadata to audio file tags
* Process directories recursively
* Manually edit artist, album, genre, and label tags
* Batch edit multiple files with the same values
* Move and rename files into a structured `label/artist/album/track title` hierarchy

## Building

To build the project, run:

```sh
cargo build --release
```

## Usage

```sh
./target/release/hakuna [OPTIONS] [PATH]...
```

### Arguments

*   `<PATH>...`: One or more files or directories to analyze. Defaults to the current directory when not provided.

### Options

*   `--artist <ARTIST>`: Artist name for metadata lookup.
*   `--album <ALBUM>`: Album name for metadata lookup.
*   `--read`: Read tags from file and show proposed metadata.
*   `--write`: Write fetched metadata to audio file tags.
*   `-e`, `--edit`: Manually edit artist, album, genre, and label tags.
*   `-m`, `--move`: Move and rename files into a `label/artist/album/track title` hierarchy based on their tags. Falls back to `artist/album/track title` when no label tag is set.
*   `-o`, `--output-dir <DIR>`: Output directory for moved files (defaults to each file's own directory).
*   `-n`, `--dry-run`: Show what would be moved without moving any files.
*   `-d`, `--discogs-token <TOKEN>`: Discogs API token for better results.
*   `-h`, `--help`: Print help information.
*   `-V`, `--version`: Print version information.

### Example

```sh
# Fetch metadata for an artist and album
./target/release/hakuna --artist 'The Beatles' --album 'Abbey Road'

# Read tags from a single file
./target/release/hakuna --read file.flac

# Write metadata to a single file
./target/release/hakuna -d DISCOGS_TOKEN --write file.flac

# Edit tags for a single file (interactive)
./target/release/hakuna --edit file.flac

# Edit tags for all files in the current directory
./target/release/hakuna --edit

# Write metadata to all files in a directory
./target/release/hakuna -d DISCOGS_TOKEN --write --all /path/to/music/

# Batch edit all files in a directory with the same values
./target/release/hakuna --edit --all /path/to/music/

# Move and rename files based on their current tags
./target/release/hakuna --move /path/to/music/

# Write tags and move in one pass, moving files to a new location
./target/release/hakuna -d DISCOGS_TOKEN --write --move --output-dir /music/library/ /path/to/incoming/

# Preview what would be moved without moving anything
./target/release/hakuna --move --dry-run /path/to/music/
```

## API Credentials

The tool can use either Discogs or MusicBrainz.

*   **Discogs (Recommended):** For better results, especially for genre and label information, a Discogs token is required. You can get one from your Discogs developer settings.

    Pass the token via command line:
    ```bash
    hakuna -d DISCOGS_TOKEN --write file.flac
    ```

*   **MusicBrainz (Fallback):** If no Discogs token is provided, the tool will fall back to using the MusicBrainz API, which does not require authentication. Results might be less detailed.