/**
* Returns the description for the given id from ann
* @param annId
* @return the description for the given id from ann
*/
private String getAnnDescription(String annId) {
try {
String url = "http://66.207.162.94/encyclopedia/anime.php?id=" + annId;
HttpClient client = new HttpClient();
HttpMethod method = new GetMethod(url);
client.executeMethod(method);
StringWriter sw = new StringWriter();
InputStream pageStream = method.getResponseBodyAsStream();
IOUtils.copy(pageStream, sw);
String page = sw.toString();
Pattern pattern = Pattern.compile(".*
(Plot Summary\\:.*?.*)", Pattern.MULTILINE | Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(page);
if (matcher.matches()) {
String match = matcher.group(1);
Pattern innerPattern = Pattern.compile("(.*)(.*?)(.*)", Pattern.MULTILINE | Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
Matcher m = innerPattern.matcher(match);
while (m.matches()) {
match = m.group(1)+m.group(2)+m.group(3);
m = innerPattern.matcher(match);
}
match = match.replaceAll("(?m)(?i)(?s).*", "");
match = match.replaceAll("(?m)(?i)(?s)<[^>]*?>", "");
match = match.replaceFirst("Plot Summary:", "");
match = match.trim();
match = match.replaceAll("\\s\\s", " ");
return match;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}