* morituri/image/table.py:

* morituri/image/toc.py:
	  Add parsing of ISRC codes.
	  Add first part of CDTEXT stuff.
	* morituri/test/test_image_toc.py:
	  Add test for converting .toc to .cue
	* morituri/test/cure.cue
	  Add reference for converted cure.toc
This commit is contained in:
Thomas Vander Stichele
2009-05-14 08:21:28 +00:00
parent 4040fafd3f
commit 82db5d3b1d
5 changed files with 128 additions and 5 deletions

View File

@@ -30,6 +30,9 @@ import re
from morituri.common import common, log
from morituri.image import table
# shared
_CDTEXT_CANDIDATE_RE = re.compile(r'(?P<key>s+) "(?P<value>.+")')
# header
_CATALOG_RE = re.compile(r'^CATALOG "(?P<catalog>\d+)"$')
@@ -39,6 +42,8 @@ _TRACK_RE = re.compile(r"""
\s(?P<mode>.+)$ # mode (AUDIO, MODEx/2xxx, ...)
""", re.VERBOSE)
_ISRC_RE = re.compile(r'^ISRC "(?P<isrc>\w+)"$')
# a HTOA is marked in the cdrdao's TOC as SILENCE
_SILENCE_RE = re.compile(r"""
^SILENCE # SILENCE
@@ -91,9 +96,18 @@ class TocFile(object, log.Loggable):
for number, line in enumerate(handle.readlines()):
line = line.rstrip()
# look for CDTEXT stuff in either header or tracks
m = _CDTEXT_CANDIDATE_RE.search(line)
if m:
key = m.group('key')
value = m.group('value')
# print key, value
# look for header elements
m = _CATALOG_RE.search(line)
if m:
catalog = m.group('catalog')
self.table.catalog = m.group('catalog')
self.debug("Found catalog number %s", self.table.catalog)
# look for TRACK lines
m = _TRACK_RE.search(line)
@@ -120,6 +134,13 @@ class TocFile(object, log.Loggable):
self.table.tracks.append(currentTrack)
continue
# look for ISRC lines
m = _ISRC_RE.search(line)
if m:
isrc = m.group('isrc')
currentTrack.isrc = isrc
self.debug('Found ISRC code %s', isrc)
# look for SILENCE lines
m = _SILENCE_RE.search(line)
if m: