| 1 | |
package org.jaudiotagger.fix; |
| 2 | |
|
| 3 | |
import org.jaudiotagger.audio.ogg.OggFileReader; |
| 4 | |
import org.jaudiotagger.audio.AudioFile; |
| 5 | |
import org.jaudiotagger.fix.Fix; |
| 6 | |
|
| 7 | |
import java.io.File; |
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | 0 | public class Fix202 |
| 14 | |
{ |
| 15 | |
|
| 16 | |
public static void main(final String[] args) |
| 17 | |
{ |
| 18 | 0 | Fix202 test = new Fix202(); |
| 19 | |
|
| 20 | 0 | if (args.length != 1) |
| 21 | |
{ |
| 22 | 0 | System.err.println("usage Fix202 Folder"); |
| 23 | 0 | System.err.println(" You must enter the folder containing the corrupted files"); |
| 24 | 0 | System.exit(1); |
| 25 | |
} |
| 26 | |
|
| 27 | 0 | File dir = new File(args[0]); |
| 28 | |
|
| 29 | 0 | if (!dir.exists()) |
| 30 | |
{ |
| 31 | 0 | System.err.println("usage Fix202 Folder"); |
| 32 | 0 | System.err.println(" File " + args[0] + " does not exist"); |
| 33 | 0 | System.exit(1); |
| 34 | |
} |
| 35 | 0 | if (!dir.isDirectory()) |
| 36 | |
{ |
| 37 | 0 | System.err.println("usage Fix202 Folder"); |
| 38 | 0 | System.err.println(" File " + args[0] + " is not a folder"); |
| 39 | 0 | System.exit(1); |
| 40 | |
} |
| 41 | |
|
| 42 | |
try |
| 43 | |
{ |
| 44 | 0 | final File[] audioFiles = dir.listFiles(new OggFileFilter()); |
| 45 | 0 | if (audioFiles.length > 0) |
| 46 | |
{ |
| 47 | 0 | for (File oggFile : audioFiles) |
| 48 | |
{ |
| 49 | 0 | System.out.print("Processing " + oggFile.getPath() +" "); |
| 50 | |
try |
| 51 | |
{ |
| 52 | |
|
| 53 | 0 | OggFileReader fileReader = new OggFileReader(); |
| 54 | 0 | AudioFile audioFile = fileReader.read(oggFile); |
| 55 | |
|
| 56 | |
|
| 57 | 0 | System.out.println(":Not Broken"); |
| 58 | 0 | continue; |
| 59 | |
|
| 60 | |
} |
| 61 | 0 | catch (Throwable t) |
| 62 | |
{ |
| 63 | |
|
| 64 | |
} |
| 65 | |
|
| 66 | |
try |
| 67 | |
{ |
| 68 | |
|
| 69 | 0 | OggFileReader fileReader = new OggFileReader(Fix.FIX_OGG_VORBIS_COMMENT_NOT_COUNTING_EMPTY_COLUMNS); |
| 70 | 0 | AudioFile audioFile = fileReader.read(oggFile); |
| 71 | 0 | audioFile.commit(); |
| 72 | |
|
| 73 | |
|
| 74 | 0 | fileReader = new OggFileReader(); |
| 75 | 0 | audioFile = fileReader.read(oggFile); |
| 76 | 0 | audioFile.commit(); |
| 77 | 0 | System.out.println(":********Fixed*************"); |
| 78 | |
|
| 79 | |
} |
| 80 | 0 | catch (Throwable t) |
| 81 | |
{ |
| 82 | 0 | System.err.println("Unable to fix"); |
| 83 | 0 | } |
| 84 | |
} |
| 85 | |
} |
| 86 | |
} |
| 87 | 0 | catch (Exception e) |
| 88 | |
{ |
| 89 | 0 | System.err.println("Unable to extract tag"); |
| 90 | 0 | System.exit(1); |
| 91 | 0 | } |
| 92 | 0 | } |
| 93 | |
|
| 94 | 0 | static class OggFileFilter |
| 95 | |
extends javax.swing.filechooser.FileFilter |
| 96 | |
implements java.io.FileFilter |
| 97 | |
{ |
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
public OggFileFilter() |
| 106 | 0 | { |
| 107 | 0 | } |
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
public final boolean accept(final File file) |
| 120 | |
{ |
| 121 | 0 | return ( |
| 122 | |
(file.getName()).toLowerCase().endsWith(".ogg") |
| 123 | |
|
| 124 | |
); |
| 125 | |
} |
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
|
| 130 | |
|
| 131 | |
|
| 132 | |
public final String getDescription() |
| 133 | |
{ |
| 134 | 0 | return new String(".ogg Files"); |
| 135 | |
} |
| 136 | |
} |
| 137 | |
|
| 138 | |
public static final String IDENT = "$Id: Fix202.java,v 1.1 2008/02/21 14:26:33 paultaylor Exp $"; |
| 139 | |
|
| 140 | |
} |