/** * @param torrent * @param maxDelayMS TODO */ public static void updateMetaData(final TOTorrent torrent, long maxDelayMS) { if (!isContent(torrent, true)) { log(torrent, "torrent " + new String(torrent.getName()) + " not az content"); return; } log(torrent, "updateMD"); PlatformTorrentMessenger.getMetaData( new TOTorrent[] {torrent}, maxDelayMS, new PlatformTorrentMessenger.GetMetaDataReplyListener() { public void messageSent() {} public void replyReceived(String replyType, Map mapHashes) { updateMetaData_handleReply(torrent, null, replyType, mapHashes); } }); }
public static boolean generate_audio_info_xml( File saveLocation, TOTorrent inTorrent, File metaFile) { Map<String, Properties> audio_file_properties = new HashMap<String, Properties>(); if (inTorrent.isSimpleTorrent()) { Properties p = new Properties(); InOrderType type = InOrderType.getType(saveLocation.getName()); if (type != null) { if (type.getFileTypeFilter().equals(FileTypeFilter.Audio)) { try { AudioFile f = AudioFileIO.read(saveLocation); Tag tag = f.getTag(); if (tag != null) { AudioHeader audioHeader = f.getAudioHeader(); setPropsFromTagAndHeader(p, audioHeader, tag); } if (p.size() > 0) { audio_file_properties.put(saveLocation.getName(), p); } } catch (Exception e) { System.err.println("audio tag parse error: " + e.toString()); } } } } else { for (TOTorrentFile torrent_file : inTorrent.getFiles()) { Properties p = new Properties(); audio_file_properties.put(torrent_file.getRelativePath(), p); InOrderType type = InOrderType.getType(torrent_file.getRelativePath()); if (type != null) { if (type.getFileTypeFilter().equals(FileTypeFilter.Audio)) { try { File file = new File(saveLocation, torrent_file.getRelativePath()); AudioFile f = AudioFileIO.read(file); Tag tag = f.getTag(); if (tag != null) { AudioHeader audioHeader = f.getAudioHeader(); setPropsFromTagAndHeader(p, audioHeader, tag); if (p.size() > 0) { audio_file_properties.put(saveLocation.getName(), p); } } } catch (Exception e) { System.err.println("audio tag parse error: " + e.toString()); } } // if it's an audio type } // if this file has a recognizable type } // for over torrent files } if (audio_file_properties.size() > 0) { try { XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(metaFile))); encoder.writeObject(audio_file_properties); encoder.close(); logger.fine( "wrote audio properties xml for: " + (new String(inTorrent.getName(), "UTF-8"))); } catch (Exception e) { try { logger.warning( "error writing audio properties for: " + new String(inTorrent.getName(), "UTF-8") + " / " + e.toString()); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } e.printStackTrace(); return false; } return true; } return false; }