mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-31 13:48:01 +00:00
25 lines
885 B
Python
25 lines
885 B
Python
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>'''
|
|
|
|
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)
|