You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
1.9 KiB

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package moe.nekojimi.musicsearcher;
import java.net.URL;
/**
*
* @author jim
*/
public class Result
{
private URL link;
private String artist;
private String album;
private String title;
public URL getLink() {
return link;
}
public void setLink(URL link) {
this.link = link;
}
public String getArtist() {
return artist;
}
public void setArtist(String artist) {
this.artist = artist;
}
public String getAlbum() {
return album;
}
public void setAlbum(String album) {
this.album = album;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public String toString() {
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 + " ";
}
}
}
}
}