Skip to content

Commit

Permalink
Update AcousticBrainz Tags with configurable tag names.
Browse files Browse the repository at this point in the history
Fix author names to point to email.
  • Loading branch information
regorxxx committed May 25, 2022
1 parent 7c18fe7 commit 29fe188
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
23 changes: 17 additions & 6 deletions plugins/acousticbrainz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
# =============================================================================

PLUGIN_NAME = 'AcousticBrainz Tags'
PLUGIN_AUTHOR = ('Wargreen <[email protected]>, '
'Hugo Geoffroy "pistache" <[email protected]>, '
'Philipp Wolfer <[email protected]>')
PLUGIN_AUTHOR = ('<a href="mailto:[email protected]">Wargreen</a>, '
'<a href="mailto:[email protected]">Hugo Geoffroy "pistache"</a>, '
'<a href="mailto:[email protected]">Philipp Wolfer</a>, '
'<a href="mailto:[email protected]">Regorxxx</a>')
PLUGIN_DESCRIPTION = '''
Tag files with tags from the AcousticBrainz database, all highlevel classifiers
and tonal/rhythm data.
Expand All @@ -38,7 +39,7 @@

PLUGIN_LICENSE = "GPL-2.0"
PLUGIN_LICENSE_URL = "https://www.gnu.org/licenses/gpl-2.0.txt"
PLUGIN_VERSION = "2.2.1"
PLUGIN_VERSION = "2.2.2"
PLUGIN_API_VERSIONS = ["2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7"]

# Plugin configuration
Expand Down Expand Up @@ -116,7 +117,9 @@ def __init__(self, recording_id, metadata, level, data, files=None):
self.data = self._extract_data(data)
self.files = files
self.do_simplemood = config.setting["acousticbrainz_add_simplemood"]
self.simplemood_tagname = config.setting["acousticbrainz_simplemood_tagname"]
self.do_simplegenre = config.setting["acousticbrainz_add_simplegenre"]
self.simplegenre_tagname = config.setting["acousticbrainz_simplegenre_tagname"]
self.do_keybpm = config.setting["acousticbrainz_add_keybpm"]
self.do_fullhighlevel = config.setting["acousticbrainz_add_fullhighlevel"]
self.do_sublowlevel = config.setting["acousticbrainz_add_sublowlevel"]
Expand Down Expand Up @@ -208,6 +211,7 @@ def update_metadata(self, name, values):
def process_simplemood(self):
self.debug("processing simplemood data")

mood_tagname = self.simplemood_tagname;
moods = []

for classifier, data in self.data.items():
Expand All @@ -217,11 +221,12 @@ def process_simplemood(self):
if classifier.startswith("mood_") and not inverted:
moods.append(value)

self.update_metadata('mood', moods)
self.update_metadata(mood_tagname, moods)

def process_simplegenre(self):
self.debug("processing simplegenre data")

genre_tagname = self.simplegenre_tagname;
genres = []

for classifier, data in self.data.items():
Expand All @@ -231,7 +236,7 @@ def process_simplegenre(self):
if classifier.startswith("genre_") and not inverted:
genres.append(value)

self.update_metadata('genre', genres)
self.update_metadata(genre_tagname, genres)

def process_fullhighlevel(self):
self.debug("processing fullhighlevel data")
Expand Down Expand Up @@ -441,7 +446,9 @@ class AcousticBrainzOptionsPage(OptionsPage):

options = [
config.BoolOption("setting", "acousticbrainz_add_simplemood", True),
config.TextOption("setting", "acousticbrainz_simplemood_tagname", "ab:mood"),
config.BoolOption("setting", "acousticbrainz_add_simplegenre", True),
config.TextOption("setting", "acousticbrainz_simplegenre_tagname", "ab:genre"),
config.BoolOption("setting", "acousticbrainz_add_keybpm", False),
config.BoolOption("setting", "acousticbrainz_add_fullhighlevel", False),
config.BoolOption("setting", "acousticbrainz_add_sublowlevel", False)
Expand All @@ -455,15 +462,19 @@ def __init__(self, parent=None):
def load(self):
setting = config.setting
self.ui.add_simplemood.setChecked(setting["acousticbrainz_add_simplemood"])
self.ui.simplemood_tagname.setText(setting["acousticbrainz_simplemood_tagname"])
self.ui.add_simplegenre.setChecked(setting["acousticbrainz_add_simplegenre"])
self.ui.simplegenre_tagname.setText(setting["acousticbrainz_simplegenre_tagname"])
self.ui.add_fullhighlevel.setChecked(setting["acousticbrainz_add_fullhighlevel"])
self.ui.add_keybpm.setChecked(setting["acousticbrainz_add_keybpm"])
self.ui.add_sublowlevel.setChecked(setting["acousticbrainz_add_sublowlevel"])

def save(self):
setting = config.setting
setting["acousticbrainz_add_simplemood"] = self.ui.add_simplemood.isChecked()
setting["acousticbrainz_simplemood_tagname"] = string_(self.ui.simplemood_tagname.text())
setting["acousticbrainz_add_simplegenre"] = self.ui.add_simplegenre.isChecked()
setting["acousticbrainz_simplegenre_tagname"] = string_(self.ui.simplegenre_tagname.text())
setting["acousticbrainz_add_keybpm"] = self.ui.add_keybpm.isChecked()
setting["acousticbrainz_add_fullhighlevel"] = self.ui.add_fullhighlevel.isChecked()
setting["acousticbrainz_add_sublowlevel"] = self.ui.add_sublowlevel.isChecked()
Expand Down
18 changes: 18 additions & 0 deletions plugins/acousticbrainz/ui_options_acousticbrainz_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,25 @@ def setupUi(self, AcousticBrainzOptionsPage):
self.add_simplemood = QtWidgets.QCheckBox(self.acousticbrainzTags_groupBox)
self.add_simplemood.setObjectName("add_simplemood")
self.verticalLayout_2.addWidget(self.add_simplemood)

self.simplemood_tagname_label = QtWidgets.QLabel(self.acousticbrainzTags_groupBox)
self.simplemood_tagname_label.setObjectName("simplemood_tagname_label")
self.verticalLayout_2.addWidget(self.simplemood_tagname_label)
self.simplemood_tagname = QtWidgets.QLineEdit(self.acousticbrainzTags_groupBox)
self.simplemood_tagname.setObjectName("simplemood_tagname")
self.verticalLayout_2.addWidget(self.simplemood_tagname)

self.add_simplegenre = QtWidgets.QCheckBox(self.acousticbrainzTags_groupBox)
self.add_simplegenre.setObjectName("add_simplegenre")
self.verticalLayout_2.addWidget(self.add_simplegenre)

self.simplegenre_tagname_label = QtWidgets.QLabel(self.acousticbrainzTags_groupBox)
self.simplegenre_tagname_label.setObjectName("simplegenre_tagname_label")
self.verticalLayout_2.addWidget(self.simplegenre_tagname_label)
self.simplegenre_tagname = QtWidgets.QLineEdit(self.acousticbrainzTags_groupBox)
self.simplegenre_tagname.setObjectName("simplegenre_tagname")
self.verticalLayout_2.addWidget(self.simplegenre_tagname)

self.add_keybpm = QtWidgets.QCheckBox(self.acousticbrainzTags_groupBox)
self.add_keybpm.setObjectName("add_keybpm")
self.verticalLayout_2.addWidget(self.add_keybpm)
Expand All @@ -55,7 +71,9 @@ def retranslateUi(self, AcousticBrainzOptionsPage):
_translate = QtCore.QCoreApplication.translate
self.acousticbrainzTags_groupBox.setTitle(_translate("AcousticBrainzOptionsPage", "AcousticBrainz Tags"))
self.add_simplemood.setText(_translate("AcousticBrainzOptionsPage", "Add simple Mood tags"))
self.simplemood_tagname_label.setText(_translate("AcousticBrainzOptionsPage", "Mood tag name:"))
self.add_simplegenre.setText(_translate("AcousticBrainzOptionsPage", "Add simple Genre tags"))
self.simplegenre_tagname_label.setText(_translate("AcousticBrainzOptionsPage", "Genre tag name:"))
self.add_keybpm.setText(_translate("AcousticBrainzOptionsPage", "Add simple BPM and Key tags"))
self.add_fullhighlevel.setText(_translate("AcousticBrainzOptionsPage", "Add all highlevel AcousticBrainz tags"))
self.add_sublowlevel.setText(_translate("AcousticBrainzOptionsPage", "Add a subset of the lowlevel AcousticBrainz tags"))
Expand Down
20 changes: 20 additions & 0 deletions plugins/acousticbrainz/ui_options_acousticbrainz_tags.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="simplemood_tagname_label">
<property name="text">
<string>Mood tag name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="simplemood_tagname"/>
</item>
<item>
<widget class="QCheckBox" name="add_simplegenre">
<property name="text">
Expand All @@ -38,6 +48,16 @@
</widget>
</item>
<item>
<item>
<widget class="QLabel" name="simplegenre_tagname_label">
<property name="text">
<string>Genre tag name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="simplegenre_tagname"/>
</item>
<widget class="QCheckBox" name="add_keybpm">
<property name="text">
<string>Add simple BPM and Key tags</string>
Expand Down

0 comments on commit 29fe188

Please sign in to comment.