1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-04 08:25:03 -05:00

* parse data from /releaseinfo page (smaller size and less likely to change)

This commit is contained in:
Reinhard Pointner 2012-02-22 08:18:25 +00:00
parent c1fbf8fbb3
commit 3f5bdfc34d

View File

@ -94,9 +94,9 @@ public class IMDbClient implements MovieIdentificationService {
protected Movie scrapeMovie(Document dom) { protected Movie scrapeMovie(Document dom) {
try { try {
String name = selectString("//H1/text()", dom); String name = selectString("//H1/A/text()", dom);
String year = new Scanner(selectString("//H1//SPAN", dom)).useDelimiter("\\D+").next(); String year = new Scanner(selectString("//H1/A/following::A/text()", dom)).useDelimiter("\\D+").next();
String url = selectString("//LINK[@rel='canonical']/@href", dom); String url = selectString("//H1/A/@href", dom);
return new Movie(name, Pattern.matches("\\d{4}", year) ? Integer.parseInt(year) : -1, getImdbId(url)); return new Movie(name, Pattern.matches("\\d{4}", year) ? Integer.parseInt(year) : -1, getImdbId(url));
} catch (Exception e) { } catch (Exception e) {
// ignore, we probably got redirected to an error page // ignore, we probably got redirected to an error page
@ -107,7 +107,7 @@ public class IMDbClient implements MovieIdentificationService {
@Override @Override
public Movie getMovieDescriptor(int imdbid, Locale locale) throws Exception { public Movie getMovieDescriptor(int imdbid, Locale locale) throws Exception {
return scrapeMovie(parsePage(new URL("http", host, String.format("/title/tt%07d/", imdbid)))); return scrapeMovie(parsePage(new URL("http", host, String.format("/title/tt%07d/releaseinfo", imdbid))));
} }