1 package net.nutch.parse.mp3; 2 3 import net.nutch.parse.Outlink; 4 5 import java.net.MalformedURLException ; 6 import java.util.ArrayList ; 7 import java.util.Properties ; 8 9 13 public class MetadataCollector { 14 15 private Properties metadata = new Properties (); 16 private String title = null; 17 private String artist = null; 18 private String album = null; 19 private ArrayList links = new ArrayList (); 20 private String text = ""; 21 22 public void notifyProperty(String name, String value) throws MalformedURLException { 23 if (name.equals("TIT2-Text")) 24 setTitle(value); 25 if (name.equals("TALB-Text")) 26 setAlbum(value); 27 if (name.equals("TPE1-Text")) 28 setArtist(value); 29 30 if (name.indexOf("URL Link") > -1) { 31 links.add(new Outlink(value, "")); 32 } else if (name.indexOf("Text") > -1) { 33 text += value + "\n"; 34 } 35 36 metadata.setProperty(name, value); 37 } 38 39 public void putAll(Properties properties) { 40 metadata.putAll(properties); 41 } 42 43 public Properties getData() { 44 return metadata; 45 } 46 47 public Outlink[] getOutlinks() { 48 return (Outlink[]) links.toArray(new Outlink[links.size()]); 49 } 50 51 public String getTitle() { 52 String text = ""; 53 if (title != null) { 54 text = title; 55 } 56 if (album != null) { 57 if (!text.equals("")) { 58 text += " - " + album; 59 } else { 60 text = title; 61 } 62 } 63 if (artist != null) { 64 if (!text.equals("")) { 65 text += " - " + artist; 66 } else { 67 text = artist; 68 } 69 } 70 return text; 71 } 72 73 public void setTitle(String title) { 74 this.title = title; 75 } 76 77 public void setArtist(String artist) { 78 this.artist = artist; 79 } 80 81 public void setAlbum(String album) { 82 this.album = album; 83 } 84 85 public String getText() { 86 return text; 87 } 88 89 } | Popular Tags |