Added initial support for parsing album-artist fields.

master
Nekojimi 3 years ago
parent d3f083e0d5
commit fe210ad8d0
  1. 27
      src/main/java/moe/nekojimi/musicsearcher/Result.java

@ -54,6 +54,33 @@ public class Result
public String toString() { public String toString() {
return "Result{" + "link=" + link + ", artist=" + artist + ", album=" + album + ", title=" + title + '}'; return "Result{" + "link=" + link + ", artist=" + artist + ", album=" + album + ", title=" + title + '}';
} }
public void setAlbumArtist(String field)
{
// System.out.println("Parsing album-artist: " + field);
String fieldLower = field.toLowerCase();
if (fieldLower.contains("from") || field.toLowerCase().contains("by"))
{
artist = "";
album = "";
String[] words = field.split("\\s+");
boolean readingArtist = false;
for (String word: words)
{
if (word.equals("from"))
readingArtist = false;
else if (word.equals("by"))
readingArtist = true;
else
{
if (readingArtist)
artist += word + " ";
else
album += word + " ";
}
}
}
}
} }

Loading…
Cancel
Save