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