Skip to content

Support for disc number in path templates (multi-disc releases) #165

@jee-r

Description

@jee-r

Hi @sentriz,

First of all, thanks for wrtag — I’ve been using Beets + Betanin for years, and I’m currently trying to migrate my tagging workflow to wrtag.

With Beets, my paths configuration looked like this:

paths:
  default: $artist_fallback - $album ($fixedyear)/%if{$multidisc,$disc.}$track - $title
  albumtype:single: $artist_fallback - $album ($fixedyear) [Single]/%if{$multidisc,$disc.}$track - $title
  albumtype:ep: $artist_fallback - $album%if{$ep_not_in_title, ($fixedyear) [EP]}/%if{$multidisc,$disc.}$track - $title
  albumtype:live: $artist_fallback - $album ($fixedyear) [Live]/%if{$multidisc,$disc.}$track - $title
  albumtype:bootleg: $artist_fallback - $album ($fixedyear) [Bootleg]/%if{$multidisc,$disc.}$track - $title
  albumtype:soundtrack: $artist_fallback - $album ($fixedyear) [Soundtrack]/%if{$multidisc,$disc.}$track - $title - $artist
  singleton: $artist_fallback - $album ($fixedyear) [Single]/%if{$multidisc,$disc.}$track - $title - $artist
  comp: $albumartist - $album ($fixedyear)/%if{$multidisc,$disc.}$track - $title - $artist

This way, Beets automatically handled multi-disc releases by prefixing track numbers with the disc number only when needed, e.g.:

# disc 1
Pink Floyd - The Wall (1979)/01.01 - In the Flesh.opus
...
# disc 2 
Pink Floyd - The Wall (1979)/02.01 - Hey You.opus

There are some adjustements to do but my current pathFormat in wrtag looks like:

/Media/Music/Opus/{{ artists .Release.Artists | sort | join "; " | safepath }} - {{ .Release.Title | safepath }}{{ if not (eq .ReleaseDisambiguation "") }} ({{ .ReleaseDisambiguation | safepath }}){{ end }} ({{ .Release.ReleaseGroup.FirstReleaseDate.Year }}){{ if ne .Release.ReleaseGroup.PrimaryType "Album" }} [{{ .Release.ReleaseGroup.PrimaryType }}]{{ end }}/{{ pad0 2 .TrackNum }}.{{ len .Tracks | pad0 2 }} {{ if .IsCompilation }}{{ artistsString .Track.Artists | safepath }} - {{ end }}{{ .Track.Title | safepath }}{{ .Ext }}

I saw in the docs that {{ len .Tracks | pad0 2 }} gives the total number of tracks, not the disc number.
Looking at musicbrainz/musicbrainz.go I couldn’t find any field exposing .Track.DiscNumber or something similar.

Would it be possible to expose:

.Track.DiscNumber → the disc number of the track

.Release.Discs (or equivalent) → to check if a release has multiple discs

That way we could write templates like:

{{ if gt (len .Release.Discs) 1 }}
{{ pad0 2 .Track.DiscNumber }}.{{ pad0 2 .Track.TrackNum }}
{{ else }}
{{ pad0 2 .Track.TrackNum }}
{{ end }}

Which would give the exact same flexibility as Beets with %if{$multidisc,$disc.}$track.

Thanks again for your work 🙏

Note:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions