Fixed regex handling.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@1277 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2003-10-24 18:34:28 +00:00
parent 7a196de228
commit 3227b27ef4
3 changed files with 17 additions and 10 deletions
@@ -1,5 +1,5 @@
// //
// $Id: CDParanoiaRipper.java,v 1.8 2003/10/10 21:30:42 mdb Exp $ // $Id: CDParanoiaRipper.java,v 1.9 2003/10/24 18:34:28 mdb Exp $
package robodj.convert; package robodj.convert;
@@ -58,10 +58,10 @@ public class CDParanoiaRipper implements Ripper
// see if we match our regular expression // see if we match our regular expression
Matcher match = regex.matcher(inline); Matcher match = regex.matcher(inline);
if (match.matches()) { if (match.find()) {
flist.add(inline.substring(match.start(0), match.end(0)));
flist.add(inline.substring(match.start(1), match.end(1))); flist.add(inline.substring(match.start(1), match.end(1)));
} flist.add(inline.substring(match.start(2), match.end(2)));
}
} }
// check the return value of the process // check the return value of the process
@@ -153,11 +153,11 @@ public class CDParanoiaRipper implements Ripper
// parse the output // parse the output
Matcher match = regex.matcher(out); Matcher match = regex.matcher(out);
if (match.matches()) { if (match.matches()) {
String action = out.substring(match.start(0), match.end(0)); String action = out.substring(match.start(1), match.end(1));
long offset = -1L; long offset = -1L;
try { try {
offset = Long.parseLong( offset = Long.parseLong(
out.substring(match.start(1), match.end(1))); out.substring(match.start(2), match.end(2)));
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
// System.err.println("Malformed pos. info: " + out); // System.err.println("Malformed pos. info: " + out);
continue; continue;
@@ -1,5 +1,5 @@
// //
// $Id: LameEncoder.java,v 1.3 2003/10/10 21:30:42 mdb Exp $ // $Id: LameEncoder.java,v 1.4 2003/10/24 18:34:28 mdb Exp $
package robodj.convert; package robodj.convert;
@@ -60,9 +60,9 @@ public class LameEncoder implements Encoder
int offset = -1, total = -1; int offset = -1, total = -1;
try { try {
offset = Integer.parseInt( offset = Integer.parseInt(
out.substring(match.start(0), match.end(0)));
total = Integer.parseInt(
out.substring(match.start(1), match.end(1))); out.substring(match.start(1), match.end(1)));
total = Integer.parseInt(
out.substring(match.start(2), match.end(2)));
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
System.err.println("Malformed position info: " + out); System.err.println("Malformed position info: " + out);
continue; continue;
@@ -1,8 +1,10 @@
// //
// $Id: RipUtil.java,v 1.2 2000/10/30 22:21:11 mdb Exp $ // $Id: RipUtil.java,v 1.3 2003/10/24 18:34:28 mdb Exp $
package robodj.convert; package robodj.convert;
import com.samskivert.util.StringUtil;
/** /**
* This class contains utility functions related to ripping. * This class contains utility functions related to ripping.
*/ */
@@ -44,6 +46,11 @@ public class RipUtil
*/ */
public static int computeDiscLength (Ripper.TrackInfo[] info) public static int computeDiscLength (Ripper.TrackInfo[] info)
{ {
if (info == null || info.length == 0) {
String errmsg = "Must have at least one track to compute disc " +
"length [info=" + StringUtil.toString(info) + "]";
throw new IllegalArgumentException(errmsg);
}
return (info[info.length-1].offset + return (info[info.length-1].offset +
info[info.length-1].length - info[info.length-1].length -
info[0].offset)/FRAMES_PER_SECOND; info[0].offset)/FRAMES_PER_SECOND;