repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
tagx.mdMarkdown179 lines8.5 KiBsource raw download

tagx — turn a download folder into a library#

Downloaded music arrives with the downloader's filename and, usually, no tags at all. Every player then files it under Unknown Artist. tagx does both halves of the fix in one pass — clean the name, write the tags — and can file the result into Artist/Album folders while it is there. Quick card: tagx-cheat. Plan without touching anything: tagx … -n.

tagx -d ~/Music/gems --artist daemon --album daemon

The one command#

What "clean the name" actually removes#

Six steps, applied in this order. Each one has its own off switch.

# What Example
1 yt-dlp's video id song [dQw4w9WgXcQ].mp3 → song.mp3
2 fullwidth stand-ins | ? : / * → - `` : / (nothing)
3 decorative unicode 𝐃𝐄𝐅𝐄𝐍𝐃 𝐖𝐇𝐀𝐓'𝐒 𝐎𝐔𝐑𝐒 → Defend What's Ours
3 smart punctuation " " ' ' – — … → " " ' ' - - ...
4 uploader furniture (REUPLOAD) (Official Video) (Lyrics) (HD) (Free Download)
5 title case PART OF ME (HARDSTYLE) → Part of Me (Hardstyle)
6 spacing - evened out, runs of spaces collapsed, trailing junk trimmed

Why step 2 exists at all. | ? : / * < > \ are illegal in filenames, so yt-dlp substitutes fullwidth lookalikes — | ? : / *. Those are perfectly legal characters, which is exactly the problem: nothing ever removes them again. They survive into the tag, the playlist, the phone, and every search you ever run against the library.

Why step 3 exists. People title videos in 𝐛𝐨𝐥𝐝 and 𝓼𝓬𝓻𝓲𝓹𝓽 because YouTube strips markup but not codepoints. Those characters sort and search as nothing at all. tagx walks each character's Unicode decomposition back to ASCII.

Why title-casing needs a word list and not a rule#

There is no rule. Every shortcut has a counterexample:

So tagx carries two lists instead:

Anything containing non-ASCII is left completely alone. билборды - снег has no title case worth guessing at, and guessing would only damage it.

Tags#

Flag ID3 (mp3) MP4 (m4a) Vorbis (flac/opus)
--artist TPE1 ©ART ARTIST
--album TALB ©alb ALBUM
--albumartist TPE2 aART ALBUMARTIST
--genre TCON ©gen GENRE
--year / --date TDRC ©day DATE
--number TRCK trkn TRACKNUMBER
(title, always) TIT2 ©nam TITLE
--cover APIC covr PICTURE

ID3v2.3, deliberately#

mutagen defaults to 2.4. 2.4 is the better spec and it is also the one that Windows Explorer, several car head units, and older rekordbox/Serato builds cannot read — a DJ-adjacent library saved as 2.4 shows up blank in exactly the places it matters. So every .mp3 is saved v2_version=3.

Other containers are unaffected: m4a gets atoms, flac and opus get Vorbis comments, and none of them have a 2.3-vs-2.4 question. That cross-format writing goes through mutagen's easy mapping — one dict of plain names, three different tag systems underneath.

Cover art#

The one field with no easy mapping, because every container stores the bytes its own way:

tagx -d ~/Music/gems --artist daemon --album daemon --cover ~/art/gems.jpg

Filing into folders#

--organize moves each file to DIR/Artist/Album/Title.ext. It needs both --artist and --album, and it refuses to combine with --no-rename — moving a file is renaming it.

Tag values used as directory names get the same sanitising as filenames: / \ : * ? " < > | become -.

tagx -d ~/Music --artist VA --album Rips -R --organize     # flatten a messy tree

Collisions#

Two differently-named downloads that clean to the same title are usually two different rips, not a duplicate. So the second one gets a (2) suffix and nothing is ever overwritten:

Clarity (Hardstyle).mp3
Clarity (Hardstyle) (2).mp3

Undo#

Renaming is the half you cannot retype, so every run that moved anything writes .tagx-undo.json into the directory it worked on, and:

tagx -d DIR --undo

walks it backwards and then deletes the journal.

Turning parts off#

Flag Effect
--no-rename tag only — filenames untouched
--no-tags rename only — the audio files are never opened
--no-title set artist/album but leave each title tag alone
--keep-case no title-casing (a library that is already correct)
--keep-ids keep the trailing [videoid]
--keep-noise keep (Official Video), (REUPLOAD), (HD)
--acronym WORD one more word that stays capitalised, repeatable
--ext mp3,flac which extensions count as audio

--no-rename together with --no-tags is refused: it leaves nothing to do.

Formats#

Handled: mp3 m4a mp4 aac flac ogg opus oga wav aiff aif wma wv ape mpc. mutagen decides what a file really is by reading it, not by trusting the extension — --ext only controls which files are offered to it.

Inspecting#

tagx -d ~/Music/gems --show          # one line per file: name, artist · album
tagx -d ~/Music/gems --show -v       # plus the title tag

--show writes to stdout unstyled when piped, so tagx --show | grep -c daemon means something.

End to end#

ytget -a 'https://youtube.com/playlist?list=…' -o ~/Music/gems   # 1. grab
tagx -d ~/Music/gems --artist daemon --album daemon -n           # 2. look
tagx -d ~/Music/gems --artist daemon --album daemon --number     # 3. do it
tagx -d ~/Music/gems --show                                      # 4. check
tagx -d ~/Music/gems --undo                                      # 5. or not

Re-running is safe and cheap: a clean name cleans to itself, so a second pass renames nothing and simply rewrites the same tags.

Colour and environment#

Rose Pine via ricefx, which sits beside it in ~/.local/bin. A standalone copy on another box has no sibling to import — the built-in ramp takes over and the tool works unchanged. NO_COLOR, RICEFX_OFF, --raw, and a non-tty stderr each drop it to plain text.

Requires mutagen (pip install mutagen). Without it, --no-tags still works — that path never opens an audio file.