TheTvDBPlugin extends ImdbPlugin { @Override public boolean scanNFO(String nfo, Movie movie) { super.scanNFO(nfo, movie); boolean result = Boolean.FALSE; LOG.debug("Scanning NFO for TheTVDB Id"); String compareString = nfo.toUpperCase(); int idx = compareString.indexOf("THETVDB.COM"); if (idx > -1) { int beginIdx = compareString.indexOf("&ID="); int length = 4; if (beginIdx < idx) { beginIdx = compareString.indexOf("?ID="); } if (beginIdx < idx) { beginIdx = compareString.indexOf("&SERIESID="); length = 10; } if (beginIdx < idx) { beginIdx = compareString.indexOf("?SERIESID="); length = 10; } if (beginIdx > idx) { int endIdx = compareString.indexOf("&", beginIdx + 1); String id; if (endIdx > -1) { id = compareString.substring(beginIdx + length, endIdx); } else { id = compareString.substring(beginIdx + length); } if (StringUtils.isNotBlank(id)) { movie.setId(THETVDB_PLUGIN_ID, id.trim()); LOG.debug("TheTVDB Id found in nfo = {}", id.trim()); result = Boolean.TRUE; } } } return result; } TheTvDBPlugin(); @Override String getPluginID(); @Override boolean scan(Movie movie); String getBanner(Movie movie); @Override void scanTVShowTitles(Movie movie); @Override boolean scanNFO(String nfo, Movie movie); static Series getSeries(String id); static String findId(Movie movie); static Banners getBanners(String id); static final String THETVDB_PLUGIN_ID; static final String CACHE_SERIES; static final String CACHE_BANNERS; }
@Test public void testScanNFO() { LOG.info("scanNFO"); String nfo = "http: Movie movie = new Movie(); assertTrue("Scan failed", TVDB.scanNFO(nfo, movie)); assertEquals(String.valueOf(ID_BABYLON_5), movie.getId(TheTvDBPlugin.THETVDB_PLUGIN_ID)); nfo = "http: movie = new Movie(); assertTrue("Scan failed", TVDB.scanNFO(nfo, movie)); assertEquals(String.valueOf(ID_BABYLON_5), movie.getId(TheTvDBPlugin.THETVDB_PLUGIN_ID)); }