-
Notifications
You must be signed in to change notification settings - Fork 0
/
jack_TOCentry.py
71 lines (60 loc) · 2.72 KB
/
jack_TOCentry.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
### jack_TOCentry - class for CDDA TOCs - part ("module") of
### jack - extract audio from a CD and MP3ify it using 3rd party software
### Copyright (C) 1999,2000 Arne Zellentin <[email protected]>
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
### GNU General Public License for more details.
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
entry_fields = ['type', 'copy', 'preemphasis', 'channels', 'media',
'filename', 'start', 'length', 'pregap']
compat_fields = ['number', 'length', 'start', 'copy', 'preemphasis', 'channels', 'rip', 'bitrate', 'rip_name']
class TOCentry:
def __init__(self, raw_dict={}):
self.number = None
self.type = None
self.copy = None # means no
self.preemphasis = None # means no
self.channels = None
self.media = None # "image" or "cd"
self.image_name = None # only for image-reader: name of image
self.readable_name = None # name the file is renamed to
self.rip_name = None # name of file while ripping / encoding
self.pregap = 0
self.start = None
self.length = None
self.bitrate = None # compat?#XXX
self.rip = None # compat
if raw_dict: # for compatibility: allow to read old-style track info
num = 1
for i in compat_fields:
self.__dict__[i] = raw_dict[num]
num = num + 1
def export(self):
"compatibility"
track = []
for i in compat_fields:
track.append(self.__dict__[i])
return track
# intercept setting of attributes
def __setattr__(self, name, value):
if name == 'pregap' and value:
self.__dict__['start'] = self.start + (value - self.pregap)
self.__dict__['length'] = self.length - (value - self.pregap)
self.__dict__['pregap'] = value
else:
self.__dict__[name] = value
# for debugging purposes only.
def initialized(self):
ok = 1
for i in entry_fields:
if not self.__dict__[i]:
ok = 0
break
return ok