~nikolai/picard/plugins

« back to all changes in this revision

Viewing changes to contrib/plugins/bonusdisc.py

  • Committer: Nikolai Prokoschenko
  • Date: 2009-01-06 17:02:13 UTC
  • Revision ID: nikolai@prokoschenko.de-20090106170213-g2m4x41p0x4d4mmf
add all plugins from the wiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
PLUGIN_NAME = 'Bonus Disc'
 
2
PLUGIN_AUTHOR = 'Jan van Thiel'
 
3
PLUGIN_DESCRIPTION = '''Based on a script by Lukas Lalinsky.<br/>
 
4
<br/>
 
5
Moves bonus disc and bonus disc titles from album titles to separate tags. For example:<br/>
 
6
<em>"Sleeping With Ghosts (bonus disc: Covers)"</em>
 
7
<ul>
 
8
    <li>album = <em>"Sleeping With Ghosts"</em></li>
 
9
    <li>bonusdisc = <em>"bonus"</em></li>
 
10
    <li>bonusdisctitle = <em>"Covers"</em></li>
 
11
</ul>'''
 
12
PLUGIN_VERSION = "0.1"
 
13
PLUGIN_API_VERSIONS = ["0.9.0", "0.10"]
 
14
 
 
15
from picard.metadata import register_album_metadata_processor
 
16
import re
 
17
 
 
18
_bonusdisc_re = re.compile(r"\s+\(bonus disc(?::\s+([^)]+))?\)")
 
19
 
 
20
def remove_bonusdiscs(tagger, metadata, release):
 
21
    matches = _bonusdisc_re.search(metadata["album"])
 
22
    if matches:
 
23
        metadata["bonusdisc"] = "bonus"
 
24
        if matches.group(1):
 
25
            metadata["bonusdisctitle"] = matches.group(1)
 
26
        metadata["album"] = _bonusdisc_re.sub('', metadata["album"])
 
27
 
 
28
register_album_metadata_processor(remove_bonusdiscs)