TheTvDBPlugin extends ImdbPlugin { @Override public boolean scan(Movie movie) { String id = findId(movie); if (StringTools.isValidString(id)) { Series series = getSeries(id); if (series == null) { LOG.debug("No series information found for {}", movie.getTitle()); } else { if (OverrideTools.checkOverwriteTitle(movie, THETVDB_PLUGIN_ID)) { movie.setTitle(series.getSeriesName(), THETVDB_PLUGIN_ID); } if (OverrideTools.checkOverwriteOriginalTitle(movie, THETVDB_PLUGIN_ID)) { movie.setOriginalTitle(series.getSeriesName(), THETVDB_PLUGIN_ID); } if (OverrideTools.checkOverwriteYear(movie, THETVDB_PLUGIN_ID)) { String year = getYear(id, movie.getSeason(), LANGUAGE_PRIMARY); if (StringTools.isNotValidString(year) && StringTools.isValidString(LANGUAGE_SECONDARY)) { year = getYear(id, movie.getSeason(), LANGUAGE_SECONDARY); } movie.setYear(year, THETVDB_PLUGIN_ID); } if (OverrideTools.checkOverwriteReleaseDate(movie, THETVDB_PLUGIN_ID)) { movie.setReleaseDate(series.getFirstAired(), THETVDB_PLUGIN_ID); } if (isNotValidString(movie.getShowStatus())) { movie.setShowStatus(series.getStatus()); } if (movie.getRating(THETVDB_PLUGIN_ID) == -1 && StringUtils.isNotBlank(series.getRating())) { try { movie.addRating(THETVDB_PLUGIN_ID, (int) (Float.parseFloat(series.getRating()) * 10)); } catch (NumberFormatException ex) { LOG.trace("Failed to transform rating for series id {} = '{}', Error: {}", series.getId(), series.getRating(), ex.getMessage()); } } if (OverrideTools.checkOverwriteRuntime(movie, THETVDB_PLUGIN_ID)) { movie.setRuntime(series.getRuntime(), THETVDB_PLUGIN_ID); } if (OverrideTools.checkOverwriteCompany(movie, THETVDB_PLUGIN_ID)) { movie.setCompany(series.getNetwork(), THETVDB_PLUGIN_ID); } if (OverrideTools.checkOverwriteGenres(movie, THETVDB_PLUGIN_ID)) { movie.setGenres(series.getGenres(), THETVDB_PLUGIN_ID); } if (OverrideTools.checkOverwritePlot(movie, THETVDB_PLUGIN_ID)) { movie.setPlot(series.getOverview(), THETVDB_PLUGIN_ID); } if (OverrideTools.checkOverwriteCertification(movie, THETVDB_PLUGIN_ID)) { movie.setCertification(series.getContentRating(), THETVDB_PLUGIN_ID); } if (OverrideTools.checkOverwriteActors(movie, THETVDB_PLUGIN_ID)) { movie.setCast(series.getActors(), THETVDB_PLUGIN_ID); } if (OverrideTools.checkOverwritePeopleActors(movie, THETVDB_PLUGIN_ID)) { movie.setPeopleCast(series.getActors(), THETVDB_PLUGIN_ID); } if (includeWideBanners && isNotValidString(movie.getBannerURL()) || (forceBannerOverwrite) || movie.isDirty(DirtyFlag.BANNER)) { String bannerUrl = getBanner(movie); if (StringTools.isValidString(bannerUrl)) { movie.setBannerURL(bannerUrl); LOG.trace("Used banner {}", bannerUrl); } } getFanart(movie); scanTVShowTitles(movie); } } return Boolean.TRUE; } 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 testScan() { LOG.info("scan"); Movie movie = new Movie(); movie.setTitle("Babylon 5", TheTvDBPlugin.THETVDB_PLUGIN_ID); boolean result = TVDB.scan(movie); assertTrue("Failed to scan", result); assertEquals("Wrong title", "Babylon 5", movie.getTitle()); assertEquals("Wrong ID", String.valueOf(ID_BABYLON_5), movie.getId(TheTvDBPlugin.THETVDB_PLUGIN_ID)); }