SHA256
1
0
forked from pool/picard
picard/bonusdisc.py
OBS User autobuild f7080a3dc8 Accepting request 46222 from multimedia:apps
Copy from multimedia:apps/picard based on submit request 46222 from user saschpe

OBS-URL: https://build.opensuse.org/request/show/46222
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/picard?expand=0&rev=1
2010-09-21 10:53:13 +00:00

31 lines
1.0 KiB
Python

# -*- coding: utf-8 -*-
PLUGIN_NAME = 'Bonus Disc'
PLUGIN_AUTHOR = 'Jan van Thiel'
PLUGIN_DESCRIPTION = '''Based on a script by Lukas Lalinsky.<br/>
<br/>
Moves bonus disc and bonus disc titles from album titles to separate tags. For example:<br/>
<em>"Sleeping With Ghosts (bonus disc: Covers)"</em>
<ul>
<li>album = <em>"Sleeping With Ghosts"</em></li>
<li>bonusdisc = <em>"bonus"</em></li>
<li>bonusdisctitle = <em>"Covers"</em></li>
</ul>'''
PLUGIN_VERSION = "0.1"
PLUGIN_API_VERSIONS = ["0.9.0", "0.10"]
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)