generated from Nekojimi/JavaMavenTemplate
Added initial support for parsing album-artist fields.
This commit is contained in:
parent
d3f083e0d5
commit
fe210ad8d0
|
@ -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…
Reference in New Issue