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