if(searchQuery.contains("http://grooveshark.com/")) {
Pattern p = Pattern.compile(".*/\\s*(.*)");
Matcher m = p.matcher(searchQuery);
if(m.find()) {
final String artistID = m.group(1);
Artist artist = searchArtistByID(artistID);
if(artist != null) {
artists.add(artist);
return artists;
}
}
}
if(Utils.isNumeric(searchQuery)) {
Artist artist = searchArtistByID(searchQuery);
if(artist != null) {
artists.add(artist);
return artists;
}
}
HashMap<String, Object>[] result = gson.fromJson(Grooveshark.sendRequest("getResultsFromSearch", new HashMap<String, Object>(){{
put("query", searchQuery);
put("type", new String[] {"Artists"});
put("guts", "0");
put("ppOverride", "false");
}}), SearchResponse.class).getResult().getResult().getArtists();
if(result.length < 1) {
JOptionPane.showMessageDialog(Main.getGui(), "No search results for \"" + searchQuery + "\".");
}
for (HashMap<String, Object> hm : result) {
artists.add(new Artist(
hm.get("ArtistID"),
hm.get("Name")
));
}