picard/discnumber.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

29 lines
973 B
Python

# -*- coding: utf-8 -*-
PLUGIN_NAME = 'Disc Numbers'
PLUGIN_AUTHOR = 'Lukas Lalinsky'
PLUGIN_DESCRIPTION = '''Moves disc numbers and subtitles from album titles to separate tags. For example:<br/>
<em>"Aerial (disc 1: A Sea of Honey)"</em>
<ul>
<li>album = <em>"Aerial"</em></li>
<li>discnumber = <em>"1"</em></li>
<li>discsubtitle = <em>"A Sea of Honey"</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
_discnumber_re = re.compile(r"\s+\(disc (\d+)(?::\s+([^)]+))?\)")
def remove_discnumbers(tagger, metadata, release):
matches = _discnumber_re.search(metadata["album"])
if matches:
metadata["discnumber"] = matches.group(1)
if matches.group(2):
metadata["discsubtitle"] = matches.group(2)
metadata["album"] = _discnumber_re.sub('', metadata["album"])
register_album_metadata_processor(remove_discnumbers)