diff options
| author | mikeos <mike.osipov@gmail.com> | 2013-07-17 23:40:25 +0400 |
|---|---|---|
| committer | mikeos <mike.osipov@gmail.com> | 2013-07-17 23:40:25 +0400 |
| commit | 89ed84bfc82ac16a3cf6ad53912f29d6f3f4f608 (patch) | |
| tree | 1672cf29141966b982b9031eb9ea5e21f41f96e1 /cue.py | |
| parent | be22d8c3a6461fe89661e2e0054d27a3481916a8 (diff) | |
split files using shntool + sox
Diffstat (limited to 'cue.py')
| -rw-r--r-- | cue.py | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -31,18 +31,33 @@ class Track: None if attr in ("pregap", "postgap") else "" ) + def isaudio(self): + return self.type == "AUDIO" and self.begin is not None + class File: def __init__(self, name, filetype): self.name = name self.type = filetype self._tracks = [] - def tracks(self): - return iter(self._tracks) + def tracks(self, audio_only = False): + return filter(Track.isaudio if audio_only else None, self._tracks) def add_track(self, track): self._tracks.append(track) + def isaudio(self): + return self.type == "WAVE" + + def has_audio_tracks(self): + return len(self.tracks(Track)) > 0 + + def split_points(self, info): + rate = info.sample_rate * info.bits_per_sample * info.channels / 8 + + for track in self.tracks(True)[1:]: + yield rate * track.begin / 75 + def __repr__(self): return self.name @@ -54,8 +69,8 @@ class Cue: def attrs(self): return sort_iter(self._attrs) - def files(self): - return iter(self._files) + def files(self, audio_only = False): + return filter(File.isaudio if audio_only else None, self._files) def get(self, attr): return self._attrs.get(attr, "") |
