Option for style tag location
This commit is contained in:
16
__init__.py
16
__init__.py
@@ -34,6 +34,10 @@ class DiscogsGenreOptionsPage(OptionsPage):
|
||||
self.token_input = QtWidgets.QLineEdit(self)
|
||||
self.token_input.setPlaceholderText("Account > Settings > Developers > Generate token")
|
||||
|
||||
self.style_input = QtWidgets.QLineEdit(self)
|
||||
self.style_input.setPlaceholderText("grouping")
|
||||
self.style_input.setToolTip("Metadata tag to store Discogs style (default: grouping), set it blank to disable")
|
||||
|
||||
min_overlap_layout = QtWidgets.QHBoxLayout()
|
||||
|
||||
min_overlap_label = QtWidgets.QLabel("Minimum Token Overlap", self)
|
||||
@@ -50,6 +54,8 @@ class DiscogsGenreOptionsPage(OptionsPage):
|
||||
|
||||
options_layout.addWidget(QtWidgets.QLabel("Personal Access Token (recommended for higher rate limits)", self))
|
||||
options_layout.addWidget(self.token_input)
|
||||
options_layout.addWidget(QtWidgets.QLabel("Style Tag", self))
|
||||
options_layout.addWidget(self.style_input)
|
||||
options_layout.addLayout(min_overlap_layout)
|
||||
|
||||
layout.addWidget(options_group)
|
||||
@@ -57,10 +63,12 @@ class DiscogsGenreOptionsPage(OptionsPage):
|
||||
|
||||
def load(self):
|
||||
self.token_input.setText(config.setting["discogs_personal_access_token"] or "")
|
||||
self.style_input.setText(config.setting["discogs_style_tag"] or "grouping")
|
||||
self.min_overlap_input.setValue(config.setting["discogs_minimum_token_overlap"] or 80)
|
||||
|
||||
def save(self):
|
||||
config.setting["discogs_personal_access_token"] = self.token_input.text().strip()
|
||||
config.setting["discogs_style_tag"] = self.style_input.text().strip()
|
||||
config.setting["discogs_minimum_token_overlap"] = self.min_overlap_input.value()
|
||||
|
||||
class DiscogsGenreProcessor:
|
||||
@@ -280,8 +288,10 @@ class DiscogsGenreProcessor:
|
||||
|
||||
for genre in genres:
|
||||
metadata.add('genre', genre)
|
||||
|
||||
if config.setting["discogs_style_tag"] is not None and config.setting["discogs_style_tag"] != "":
|
||||
for style in styles:
|
||||
metadata.add('style', style)
|
||||
metadata.add(config.setting["discogs_style_tag"] or "grouping", style)
|
||||
finally:
|
||||
album._requests -= 1
|
||||
if album._requests == 0:
|
||||
@@ -343,8 +353,10 @@ class DiscogsGenreProcessor:
|
||||
|
||||
for genre in genres:
|
||||
metadata.add('genre', genre)
|
||||
|
||||
if config.setting["discogs_style_tag"] is not None and config.setting["discogs_style_tag"] != "":
|
||||
for style in styles:
|
||||
metadata.add('style', style)
|
||||
metadata.add(config.setting["discogs_style_tag"] or "grouping", style)
|
||||
|
||||
finally:
|
||||
album._requests -= 1
|
||||
|
||||
@@ -4,7 +4,7 @@ from picard.config import TextOption, IntOption, Option
|
||||
PLUGIN_NAME = "Discogs Genre & Style"
|
||||
PLUGIN_AUTHOR = "cy1der"
|
||||
PLUGIN_DESCRIPTION = "Fetches genres and styles from Discogs"
|
||||
PLUGIN_VERSION = "1.0.1"
|
||||
PLUGIN_VERSION = "1.0.2"
|
||||
PLUGIN_API_VERSIONS = ["2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13"]
|
||||
PLUGIN_LICENSE = "GPL-2.0-or-later"
|
||||
PLUGIN_LICENSE_URL = "https://www.gnu.org/licenses/gpl-2.0.html"
|
||||
@@ -12,5 +12,6 @@ PLUGIN_USER_GUIDE_URL = "https://git.altaiar.dev/ahmed/picard-discogs-genre"
|
||||
|
||||
CONFIG_OPTIONS: List[Option] = [
|
||||
TextOption("setting", "discogs_personal_access_token", ""),
|
||||
TextOption("setting", "discogs_style_tag", "grouping"),
|
||||
IntOption("setting", "discogs_minimum_token_overlap", 80)
|
||||
]
|
||||
Reference in New Issue
Block a user