Skip to content

Instantly share code, notes, and snippets.

@vena
Created March 17, 2023 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vena/fadc65ab557a57f727b42196e119a03e to your computer and use it in GitHub Desktop.
Save vena/fadc65ab557a57f727b42196e119a03e to your computer and use it in GitHub Desktop.
PLUGIN_NAME = "Remaster Variables"
PLUGIN_AUTHOR = "Daniel Vena"
PLUGIN_DESCRIPTION = "Sets _album_is_remaster and _album_remaster_info variables if an album has a remaster relationship"
PLUGIN_VERSION = "0.1"
PLUGIN_API_VERSIONS = ["2.2"]
from datetime import datetime
from picard import config, log
from picard.metadata import register_album_metadata_processor
from picard.plugin import PluginPriority
# Type ID for remaster relationship
RE_UUID = "48e327b5-2d04-4518-93f1-fed5f0f0fa3c"
def find_remaster_relationship(album, metadata, release):
if "relations" in release:
for rel in release["relations"]:
if rel['type-id'] == RE_UUID:
dt = datetime.strptime(release["date"], '%Y-%m-%d')
metadata['~album_is_remaster'] = True
metadata['~album_remaster_info'] = "{} {}".format(dt.year, rel["type"].capitalize())
register_album_metadata_processor(find_remaster_relationship, priority=PluginPriority.HIGH)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment