ImdbPlugin implements MovieDatabasePlugin { @Override public boolean scanNFO(String nfo, Movie movie) { boolean result = Boolean.TRUE; if (StringTools.isValidString(movie.getId(IMDB_PLUGIN_ID))) { return result; } LOG.debug("Scanning NFO for Imdb Id"); String id = searchIMDB(nfo, movie); if (isValidString(id)) { movie.setId(IMDB_PLUGIN_ID, id); LOG.debug("IMDb Id found in nfo: {}", movie.getId(IMDB_PLUGIN_ID)); } else { int beginIndex = nfo.indexOf("/tt"); if (beginIndex != -1) { StringTokenizer st = new StringTokenizer(nfo.substring(beginIndex + 1), "/ \n,:!&ÃƒÆ’Ã†â€™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’Ã¢â‚¬Å¡Ãƒâ€šÃ‚Â©\"'(--ÃƒÆ’Ã†â€™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’Ã¢â‚¬Å¡Ãƒâ€šÃ‚Â¨_ÃƒÆ’Ã†â€™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’Ã¢â‚¬Å¡Ãƒâ€šÃ‚Â§ÃƒÆ’Ã†â€™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’Ã¢â‚¬Å¡Ãƒâ€šÃ‚Â )=$"); movie.setId(IMDB_PLUGIN_ID, st.nextToken()); LOG.debug("IMDb Id found in nfo: {}", movie.getId(IMDB_PLUGIN_ID)); } else { beginIndex = nfo.indexOf("/Title?"); if (beginIndex != -1 && beginIndex + 7 < nfo.length()) { StringTokenizer st = new StringTokenizer(nfo.substring(beginIndex + 7), "/ \n,:!&ÃƒÆ’Ã†â€™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’Ã¢â‚¬Å¡Ãƒâ€šÃ‚Â©\"'(--ÃƒÆ’Ã†â€™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’Ã¢â‚¬Å¡Ãƒâ€šÃ‚Â¨_ÃƒÆ’Ã†â€™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’Ã¢â‚¬Å¡Ãƒâ€šÃ‚Â§ÃƒÆ’Ã†â€™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’Ã¢â‚¬Å¡Ãƒâ€šÃ‚Â )=$"); movie.setId(IMDB_PLUGIN_ID, "tt" + st.nextToken()); LOG.debug("IMDb Id found in nfo: {}", movie.getId(IMDB_PLUGIN_ID)); } else { LOG.debug("No IMDb Id found in nfo !"); result = Boolean.FALSE; } } } return result; } ImdbPlugin(); @Override String getPluginID(); @Override boolean scan(Movie movie); @Override void scanTVShowTitles(Movie movie); @Override boolean scanNFO(String nfo, Movie movie); @Override boolean scan(Person person); static final String IMDB_PLUGIN_ID; }
@Test public void testScanNFO() { LOG.info("testScanNFO"); String nfo = "\nhttp: Movie movie = new Movie(); ImdbPlugin imdbPlugin = new ImdbPlugin(); imdbPlugin.scanNFO(nfo, movie); assertEquals("tt0458339", movie.getId(ImdbPlugin.IMDB_PLUGIN_ID)); }