2 # Copyright (c) 2007 Jesus Climent <jesus.climent@hispalinux.es>
3 # This code is hereby licensed for public consumption under either the
4 # GNU GPL v2 or greater, or Larry Wall's Artistic license - your choice.
6 # You should have received a copy of the GNU General Public License along
7 # with this program; if not, write to the Free Software Foundation, Inc.,
8 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
10 # $Id: abcde 232 2007-03-22 21:39:30Z data $
13 # import those needed modules.
18 version
= "1.0-$Revision$"
20 help = """This is abcde version """ + version
+ """
22 usage: abcde.py [options] [tracks]
24 -1 Encode the whole CD in a single file
25 -a <action1[,action2]...>
27 cddb,read,normalize,encode,tag,move,replaygain,playlist,clean
28 -b Enable batch normalization
30 Specify a configuration file (overrides system and user config files)
32 Specify discid to resume from (only needed if you no longer have the cd)
34 Specify CDROM device to grab (flac uses a single-track flac file)
35 -D Debugging mode (equivalent to sh -x abcde)
36 -e Erase encoded track information from status file
37 -f Force operations that otherwise are considered harmful. Read "man abcde"
38 -g Use "lame --nogap" for MP3 encoding. Disables low disk and pipes flags
39 -h This help information
40 #-i Tag files while encoding, when possible (local only) -NWY-
41 -j <#> Number of encoder processes to run at once (localhost)
42 -k Keep the wav tracks for later use
43 -l Use low disk space algorithm
44 -L Use local CDDB storage directory
45 -n No lookup. Don't query CDDB, just create and use template
46 -N Noninteractive. Never prompt for anything
47 -m Modify playlist to include CRLF endings, to comply with some players
48 WARNING: Deprecated. Use \"cue\" action
50 Output file type(s) (vorbis,mp3,flac,spx,mpc,wav,m4a). Defaults to vorbis
51 -p Pad track numbers with 0's (if less than 10 tracks)
52 -P Use UNIX pipes to read+encode without wav files
54 Set quality level (high,medium,low)
56 Also encode on these remote hosts
57 -R Use local CDDB in recursive mode
59 Show dielfs from the CDDB info (year,genre)
60 -S <#> Set the CD speed
61 -t <#> Start the track numbering at a given number
62 -T <#> Same as -t but modifies tag numbering
63 -U Do NOT use UNICODE (UTF8) tags and comments
64 -v Show version number and exit
65 -V Be a bit more verbose about what is happening behind the scenes
66 -x Eject CD after all tracks are read
68 Add a comment to the CD tracks
69 -W <#> Contatenate CDs: -T #01 -w "CD #"
70 -z Use debug CDROMREADERSYNTAX option (needs cdparanoia)
72 Tracks is a space-delimited list of tracks to grab.
73 Ranges specified with hyphens are allowed (i.e., 1-5).
80 def addstatus(status
):
83 def log(status
,logstring
):
86 def f_seq_row (min,max):
91 log(error
,"syntax error while processing track numbers")
94 def f_seq_line (min,max):
99 log(error
,"syntax error while processing track numbers")
104 # get_first and get_last can be substituted by range[0] and range[:-1]
106 # checkstatus(string)
107 # Returns "0" if the string was found, returns 1 if it wasn't
108 # Puts the blurb content, if available, on stdout.
109 # Otherwise, returns "".
110 def checkstatus (string
, file):
112 patern
= re
.compile("^"+string
+"(=.*)?$")
115 file = open(file, "r")
117 log("error","file",file,"cannot be read")
122 line
= file.readline()
124 blurb
.append(re
.search(patern
,line
).string
)
132 print checkstatus("test", "/tmp/status")