[SCM] morituri/master: * morituri/image/cue.py: publicize CueFile.tracks Add a method to get track lengths * examples/readcue.py: Use it.
js at users.alioth.debian.org
js at users.alioth.debian.org
Sun Oct 19 20:08:43 UTC 2014
The following commit has been merged in the master branch:
commit 4c2b6e4c7423f71a855693fba644cd8a6c7c5912
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date: Sat Feb 28 13:43:44 2009 +0000
* morituri/image/cue.py:
publicize CueFile.tracks
Add a method to get track lengths
* examples/readcue.py:
Use it.
diff --git a/ChangeLog b/ChangeLog
index 68cd23c..fbedc30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2009-02-28 Thomas Vander Stichele <thomas at apestaart dot org>
+ * morituri/image/cue.py:
+ publicize CueFile.tracks
+ Add a method to get track lengths
+ * examples/readcue.py:
+ Use it.
+
+2009-02-28 Thomas Vander Stichele <thomas at apestaart dot org>
+
* morituri/common/task.py (added):
Add a task abstraction.
diff --git a/examples/readcue.py b/examples/readcue.py
index 75bcbdf..05162c1 100644
--- a/examples/readcue.py
+++ b/examples/readcue.py
@@ -28,7 +28,7 @@ def main(path):
cuefile = cue.Cue(path)
cuefile.parse()
- print cuefile._tracks
+ print cuefile.tracks
path = 'test.cue'
diff --git a/morituri/image/cue.py b/morituri/image/cue.py
index 60015fb..10e3822 100644
--- a/morituri/image/cue.py
+++ b/morituri/image/cue.py
@@ -58,7 +58,7 @@ class Cue:
self._path = path
self._rems = {}
self._messages = []
- self._tracks = []
+ self.tracks = []
def parse(self):
state = 'HEADER'
@@ -100,7 +100,7 @@ class Cue:
trackMode = m.expand('\\2')
currentTrack = Track(trackNumber)
- self._tracks.append(currentTrack)
+ self.tracks.append(currentTrack)
continue
# look for INDEX lines
@@ -116,9 +116,9 @@ class Cue:
seconds = int(m.expand('\\3'))
frames = int(m.expand('\\4'))
- totalFrames = frames + seconds * 75 + minutes * 75 * 60
- currentTrack.index(indexNumber, totalFrames, currentFile)
- print 'index %d, offset %d of track %r' % (indexNumber, totalFrames, currentTrack)
+ frameOffset = frames + seconds * 75 + minutes * 75 * 60
+ currentTrack.index(indexNumber, frameOffset, currentFile)
+ # print 'index %d, offset %d of track %r' % (indexNumber, frameOffset, currentTrack)
continue
@@ -131,6 +131,24 @@ class Cue:
"""
self._messages.append((number + 1, message))
+ def getTrackLength(self, track):
+ # returns track length in frames, or -1 if can't be determined and
+ # complete file should be assumed
+ # FIXME: this assumes a track can only be in one file; is this true ?
+ i = self.tracks.index(track)
+ if i == len(self.tracks) - 1:
+ # last track, so no length known
+ return -1
+
+ thisIndex = track._indexes[1] # FIXME: could be more
+ nextIndex = self.tracks[i + 1]._indexes[1] # FIXME: could be 0
+
+ if thisIndex[1] == nextIndex[1]: # same file
+ return nextIndex[0] - thisIndex[0]
+
+ # FIXME: more logic
+ return -1
+
class File:
"""
I represent a FILE line in a cue file.
--
morituri packaging
More information about the pkg-multimedia-commits
mailing list