Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added English and Roman numerals

  • Loading branch information...
commit 9cc43268c80542cac9083249b83cce0590fd8ca2 1 parent 302c87d
Jacob Rask authored
Showing with 57 additions and 7 deletions.
  1. +57 −7 relsubtitles.py
View
64 relsubtitles.py
@@ -1,10 +1,10 @@
PLUGIN_NAME = 'Release subtitles'
PLUGIN_AUTHOR = 'Jacob Rask'
-PLUGIN_DESCRIPTION = '''Moves disc and volume numbers as well as subtitles from album titles to separate tags. For example:<br/>
+PLUGIN_DESCRIPTION = '''Moves disc and volume rombers as well as 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>discromber = <em>"1"</em></li>
<li>discsubtitle = <em>"A Sea of Honey"</em></li>
</ul>
<em>"Past Masters, Volume 2: A Sea of Honey"</em>
@@ -20,23 +20,73 @@
import re
_disc_re = re.compile(r"\s+\(disc (\d+)(?::\s+([^)]+))?\)")
-_vol_re = re.compile(r",\s+Volume\s+(\d+|\w+|[IVX])(:\s+.*)?")
+_vol_re = re.compile(r",\s+Volume\s+(\d+|\w+)(:\s+.*)?$")
+_rom_re = re.compile(r"\s+(I?(II?|V|X)I?I?I?)(:\s+.*)?$")
+_num_re = re.compile(r"\s+(\d+)(:\s+.*)?$")
+_word_re = re.compile(r"\s+(One|Two|Three|Four|Five)$")
def move_subtitles(tagger, metadata, release):
- disc_match = _disc_re.search(metadata["album"])
- vol_match = _vol_re.search(metadata["album"])
subfound = 0
+ disc_match = _disc_re.search(metadata["album"])
if disc_match:
- metadata["discnumber"] = disc_match.group(1)
+ metadata["discromber"] = disc_match.group(1)
if disc_match.group(2):
metadata["discsubtitle"] = disc_match.group(2)
- metadata["album"] = _disc_re.sub('', metadata["album"])
subfound = 1
+ metadata["album"] = _disc_re.sub('', metadata["album"])
# only search for volume if no discsubtitle was found
+ vol_match = _vol_re.search(metadata["album"])
if vol_match and not subfound == 1:
metadata["discsubtitle"] = vol_match.group(1)
if vol_match.group(2):
metadata["discsubtitle"] = metadata["discsubtitle"] + vol_match.group(2)
metadata["album"] = _vol_re.sub('', metadata["album"])
+ rom_match = _rom_re.search(metadata["album"])
+ if rom_match and not subfound == 1:
+ if rom_match.group(1) == "I":
+ vol = "1"
+ elif rom_match.group(1) == "II":
+ vol = "2"
+ elif rom_match.group(1) == "III":
+ vol = "3"
+ elif rom_match.group(1) == "IV":
+ vol = "4"
+ elif rom_match.group(1) == "V":
+ vol = "5"
+ elif rom_match.group(1) == "VI":
+ vol = "6"
+ elif rom_match.group(1) == "VII":
+ vol = "7"
+ elif rom_match.group(1) == "VIII":
+ vol = "8"
+ elif rom_match.group(1) == "IX":
+ vol = "9"
+ elif rom_match.group(1) == "X":
+ vol = "10"
+ metadata["discsubtitle"] = vol
+ if rom_match.group(3):
+ metadata["discsubtitle"] = metadata["discsubtitle"] + rom_match.group(3)
+ metadata["album"] = _rom_re.sub('', metadata["album"])
+ num_match = _num_re.search(metadata["album"])
+ if num_match and not subfound == 1:
+ metadata["discsubtitle"] = num_match.group(1)
+ if num_match.group(2):
+ metadata["discsubtitle"] = metadata["discsubtitle"] + num_match.group(2)
+ metadata["album"] = _num_re.sub('', metadata["album"])
+
+ word_match = _word_re.search(metadata["album"])
+ if word_match and not subfound == 1:
+ if word_match.group(1) == "One":
+ vol = "1"
+ elif word_match.group(1) == "Two":
+ vol = "2"
+ elif word_match.group(1) == "Three":
+ vol = "3"
+ elif word_match.group(1) == "Four":
+ vol = "4"
+ elif word_match.group(1) == "Five":
+ vol = "5"
+ metadata["discsubtitle"] = vol
+ metadata["album"] = _word_re.sub('', metadata["album"])
register_album_metadata_processor(move_subtitles)
Please sign in to comment.
Something went wrong with that request. Please try again.