new HasParentFilter(new HasAttributeFilter("href",
"/catalog/movieDetails/" + item.getMovieId())),
new NodeClassFilter(ImageTag.class)
),
new CssClassFilter("bvr-rating"),
new CssClassFilter("description")
});
parser.extractAllNodesThatMatch(infoCollector);
int i=0;
//get the icon
ImageTag icon = (ImageTag)infoCollector.getNode(i++);
item.setIconUrl(icon.getImageURL());
//strip off the query params
int index = item.getIconUrl().indexOf('?');
if (index != -1) {
item.setIconUrl(item.getIconUrl().substring(0, index)+ "?wid=130&hei=182&cvt=jpeg");
item.setIconWidth(130);
item.setIconHeight(182);
}
if (item.getIconUrl().startsWith("//")) {
item.setIconUrl("http:" + item.getIconUrl());
}
Node ratingNode = infoCollector.getNode(i++);
String ratingStr = ((Tag)ratingNode).getAttribute("src");
int rating = -1;
boolean myRating = false;
Pattern ratingPattern = Pattern.compile(RATING_IMG_EXPR);
Matcher matcher = ratingPattern.matcher(ratingStr);
if (matcher.matches()) {
myRating = "rt".equals(matcher.group(1));
rating = Integer.parseInt(matcher.group(2));
}
item.setRating(rating);
if (myRating) {
item.setMyRating(rating);
}
Node infoNode = infoCollector.getNode(i++);
//info
NodeList list = new NodeList();
NodeFilter groupsFilter = new CssClassFilter("movieInfo");
infoNode.collectInto(list, groupsFilter);
setListValues(item, list);
//summary
list.removeAll();
NodeFilter summaryFilter = new CssClassFilter("summary");
infoNode.collectInto(list, summaryFilter);
item.setSummary(NodeUtils.getTextData(list));
item.addDetailFlag(MovieItem.DETAIL_MEDIUM);