ImdbInfo { public String getImdbPersonId(String personName, String movieId) { try { if (StringTools.isValidString(movieId)) { StringBuilder sb = new StringBuilder(this.imdbSite); sb.append("search/name?name="); sb.append(URLEncoder.encode(personName, UTF_8)).append("&role=").append(movieId); LOG.debug("Querying IMDB for {}", sb.toString()); String xml = httpClient.request(sb.toString()); Matcher titlematch = this.personRegex.matcher(xml); if (titlematch.find()) { LOG.debug("IMDb returned one match {}", titlematch.group(1)); return titlematch.group(1); } String firstPersonId = HTMLTools.extractTag(HTMLTools.extractTag(xml, "<tr class=\"even detailed\">", "</tr>"), "<a href=\"/name/", "/\""); if (StringTools.isValidString(firstPersonId)) { return firstPersonId; } } return getImdbPersonId(personName); } catch (IOException ex) { LOG.error("Failed retreiving IMDb Id for person : {}", personName); LOG.error(SystemTools.getStackTrace(ex)); } return Movie.UNKNOWN; } ImdbInfo(); String getImdbId(String movieName, String year); String getImdbId(String movieName, String year, boolean isTVShow); String getImdbPersonId(String personName, String movieId); String getImdbPersonId(String personName); String getImdbSite(); Charset getCharset();  }
@Test public void testImdbPersonId() { LOG.info("testImdbPersonId"); for (String site : SITES) { PropertiesUtil.setProperty("imdb.site", site); ImdbInfo imdbInfo = new ImdbInfo(); String id = imdbInfo.getImdbPersonId("Renée Zellweger"); assertEquals("IMDb site " + site, "nm0000250", id); } }