public static Library parse(File f) throws IOException, ItlException { long fileLength = f.length(); InputStream in = new FileInputStream(f); try { return parse(in, fileLength); } finally { in.close(); } }
public static Library parse(InputStream in, long fileLength) throws IOException, ItlException { Input di = new InputImpl(in); Hdfm hdr = Hdfm.read(di, fileLength); ParseLibrary pl = new ParseLibrary(); String path = pl.drain(inputFor(hdr.fileData), hdr.fileData.length); // for (InputRange ir : pl.diagnostics) { // System.out.println(ir); // } Library library = new Library(hdr, path, pl.playlists, pl.podcasts, pl.tracks, pl.resourcesWithArtwork); return library; }
static String readGenericHohm(Input di) throws IOException, ItlException { byte[] unknown = new byte[12]; di.readFully(unknown); int dataLength = di.readInt(); expectZeroBytes(di, 8, " in HOHM block"); byte[] data = new byte[dataLength]; di.readFully(data); return toString(data, unknown[11]); }
String trackTitle = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("Title with no track defined"); String albumTitle = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("Album title with no track defined"); String artist = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("Artist with no track defined"); String genre = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("genre with no track defined"); String kind = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("kind with no track defined"); String url = readGenericHohm(di); String location = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("kind with no track defined"); expectZeroBytes(di, 4); consumed += 8;
byte[] persistentId = readPersistentId(di); expectZeroBytes(di, 40);
String title = readGenericHohm(di); going = !readHdsm(di, length); consumed = length;
static void expectZeroBytes(Input di, int count) throws IOException, ItlException { expectZeroBytes(di, count, ""); }
public static String toString(byte[] data) throws UnsupportedEncodingException { return new String(data, guessEncoding(data)); }
going = !ParseLibrary.readHdsm(new InputImpl(new ByteArrayInputStream(ba)), ba.length);
} else if(type.equals("pech")) { ParseLibrary.hexDumpBytes(di, length); } else { len -= 8;
public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Usage: ParseLibrary <iTunes Library.itl>"); System.exit(5); } File f = new File(args[0]); Library lib = parse(f); OutputStream out = new FileOutputStream("decrypted-file"); out.write(lib.hdr.fileData); out.close(); }
public static void main(String[] args) throws IOException, ItlException { if (args.length != 1) { System.err.println("Usage: ExportRatings <library.itl>"); System.exit(5); } Library lib = ParseLibrary.parse(new File(args[0])); for (Track t : lib.getTracks()) { if(t.getLocation() != null) { System.out.println(t.getLocation() + "," + t.getRating()); } } } }
Library l = ParseLibrary.parse(libFile);
Library lib = ParseLibrary.parse(libFile);