New python try of abcde
[clinton/abcde.git] / abcde.py
CommitLineData
2c5ad283 1#!env python
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.
5#
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
9#
10# $Id: abcde 232 2007-03-22 21:39:30Z data $
11
12
13# import those needed modules.
14
15import os
16import re
17
18version = "1.0-$Revision$"
19
20help = """This is abcde version """ + version + """
21
22usage: abcde.py [options] [tracks]
23Options:
24-1 Encode the whole CD in a single file
25-a <action1[,action2]...>
26 Actions to perform:
27 cddb,read,normalize,encode,tag,move,replaygain,playlist,clean
28-b Enable batch normalization
29-c <file>
30 Specify a configuration file (overrides system and user config files)
31-C <discid#>
32 Specify discid to resume from (only needed if you no longer have the cd)
33-d <device>
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
49-o <type1[,type2]...>
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
53-q <level>
54 Set quality level (high,medium,low)
55-r <host1[,host2]...>
56 Also encode on these remote hosts
57-R Use local CDDB in recursive mode
58-s <field>
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
67-w <comment>
68 Add a comment to the CD tracks
69-W <#> Contatenate CDs: -T #01 -w "CD #"
70-z Use debug CDROMREADERSYNTAX option (needs cdparanoia)
71
72Tracks is a space-delimited list of tracks to grab.
73Ranges specified with hyphens are allowed (i.e., 1-5).
74
75"""
76
77def usage ():
78 print help
79
80def addstatus(status):
81 pass
82
83def log(status,logstring):
84 pass
85
86def f_seq_row (min,max):
87 try:
88 seq = range(min,max)
89 return seq
90 except:
91 log(error,"syntax error while processing track numbers")
92 return -1
93
94def f_seq_line (min,max):
95 try:
96 seq = range(min,max)
97 return seq
98 except:
99 log(error,"syntax error while processing track numbers")
100 return -1
101
102#usage()
103
104# get_first and get_last can be substituted by range[0] and range[:-1]
105
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 "".
110def checkstatus (string, file):
111
112 patern = re.compile("^"+string+"(=.*)?$")
113
114 try:
115 file = open(file, "r")
116 except:
117 log("error","file",file,"cannot be read")
118 return -1
119
120 blurb = []
121 while 1:
122 line = file.readline()
123 if line == "": break
124 blurb.append(re.search(patern,line).string)
125
126 print blurb
127 if blurb[-1]:
128 return 0
129 else:
130 return 1
131
132print checkstatus("test", "/tmp/status")