# -*- coding: utf-8 -*-
PLUGIN_NAME = 'Bonus Disc'
PLUGIN_AUTHOR = 'Jan van Thiel'
PLUGIN_DESCRIPTION = '''Based on a script by Lukas Lalinsky.
Moves bonus disc and bonus disc titles from album titles to separate tags. For example:
"Sleeping With Ghosts (bonus disc: Covers)"
- album = "Sleeping With Ghosts"
- bonusdisc = "bonus"
- bonusdisctitle = "Covers"
'''
PLUGIN_VERSION = "0.1"
PLUGIN_API_VERSIONS = ["0.9.0", "0.10", "0.15"]
from picard.metadata import register_album_metadata_processor
import re
_bonusdisc_re = re.compile(r"\s+\(bonus disc(?::\s+([^)]+))?\)")
def remove_bonusdiscs(tagger, metadata, release):
matches = _bonusdisc_re.search(metadata["album"])
if matches:
metadata["bonusdisc"] = "bonus"
if matches.group(1):
metadata["bonusdisctitle"] = matches.group(1)
metadata["album"] = _bonusdisc_re.sub('', metadata["album"])
register_album_metadata_processor(remove_bonusdiscs)