Add track disambiguator to title? #5464
Unanswered
Gwouigwoui
asked this question in
Q&A
Replies: 2 comments 3 replies
-
Do you mean ex. "(mono single)" here? https://musicbrainz.org/recording/ca25a870-6b8d-4c44-b684-a40644c26079 And you want them in the metadata tag for title? |
Beta Was this translation helpful? Give feedback.
1 reply
-
I've taken the rewrite plugin as a base, as I also needed the extra information. Please see my code below, currently only the title is working. """Appends disambiguation information to track and album titles for path
formats.
"""
from beets import library, ui
from beets.plugins import BeetsPlugin
class MyRewritePlugin(BeetsPlugin):
def __init__(self):
super().__init__()
# Add new template fields for track title and album title with disambiguation.
# this one works
self.template_fields["title"] = lambda item: self.append_disambig(item, "title", "trackdisambig")
# this one too, but has no effect on the actual tag
self.template_fields["album"] = lambda item: self.append_disambig(item, "album", "albumdisambig")
# not working at all, got it working once :-(
# self.album_template_fields["album"] = lambda album: self.append_disambig(album, "album", "albumdisambig")
# print(self.album_template_fields["album"] )
# print("RewritePlugin initialized with template fields for title and album.")
@staticmethod
def append_disambig(item, field, disambig_field):
"""Append the disambiguation field value to the original field value.
"""
print(item._values_fixed.keys())
original_value = item._values_fixed.get(field, "")
disambig_value = item._values_fixed.get(disambig_field, "")
title_blacklist = ["live", "acoustic", "mix", "album version"] #
if field == "title":
for filter in title_blacklist:
if disambig_value in original_value or (filter in original_value and filter in disambig_value):
return original_value
# else:
# if disambig_value:
# print(disambig_value)
if disambig_value:
new_value = f"{original_value} ({disambig_value})"
# print(f"Disambiguation applied: {original_value} -> {new_value}")
return new_value
else:
# print(f"No disambiguation needed for: {original_value}")
return original_value |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The question is in the title: is there a way to add track disambiguators, if present, to the title of tracks (for albums like this one: https://musicbrainz.org/release/5f20273d-a1c9-4c7f-a9fd-8fcd2f58a4eb)?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions