AllocinePlugin extends ImdbPlugin { @Override public boolean scan(Movie movie) { String allocineId = getMovieId(movie); if (isNotValidString(movie.getId(IMDB_PLUGIN_ID))) { movie.setId(IMDB_PLUGIN_ID, imdbInfo.getImdbId(movie.getOriginalTitle(), movie.getYear(), movie.isTVShow())); LOG.debug("Found imdbId = {}", movie.getId(IMDB_PLUGIN_ID)); } boolean retval; if (isValidString(allocineId)) { if (movie.isTVShow()) { updateTVShowInfo(movie); retval = true; } else { retval = updateMovieInfo(movie, allocineId); } } else { LOG.debug("No Allocine id available, we fall back to ImdbPlugin"); retval = super.scan(movie); } return retval; } AllocinePlugin(); @Override String getPluginID(); String getMovieId(Movie movie); String getMovieId(String title, String year, int season); @Override boolean scan(Movie movie); MovieInfos getMovieInfos(String allocineId); @Override boolean scanNFO(String nfo, Movie movie); static final String ALLOCINE_PLUGIN_ID; }
@Test public void testMovie() { LOG.info("testMovie"); Movie movie = new Movie(); movie.setMovieType(Movie.TYPE_MOVIE); movie.setId(AllocinePlugin.ALLOCINE_PLUGIN_ID, "45322"); movie.setId(ImdbPlugin.IMDB_PLUGIN_ID, "tt0320691"); allocinePlugin.scan(movie); assertEquals("Underworld", movie.getTitle()); assertEquals("12", movie.getCertification()); }
@Test public void testTvSeries() { LOG.info("testTvSeries"); OverrideTools.putTvPriorities(OverrideFlag.TITLE, "allocine,thetvdb"); OverrideTools.putTvPriorities(OverrideFlag.ORIGINALTITLE, "allocine,thetvdb"); OverrideTools.putTvPriorities(OverrideFlag.PLOT, "allocine,thetvdb"); OverrideTools.putTvPriorities(OverrideFlag.OUTLINE, "allocine,thetvdb"); OverrideTools.putTvPriorities(OverrideFlag.EPISODE_TITLE, "allocine,thetvdb"); OverrideTools.putTvPriorities(OverrideFlag.EPISODE_PLOT, "allocine,thetvdb"); Movie movie = new Movie(); movie.setMovieType(Movie.TYPE_TVSHOW); movie.setId(AllocinePlugin.ALLOCINE_PLUGIN_ID, "5676"); movie.setId(ImdbPlugin.IMDB_PLUGIN_ID, "tt1634549"); MovieFile mf = new MovieFile(); mf.setSeason(1); mf.setFirstPart(1); mf.setLastPart(1); movie.addMovieFile(mf); assertTrue("Failed to scan correctly", allocinePlugin.scan(movie)); assertEquals("Incorrect series title", "Millennium", movie.getOriginalTitle()); assertFalse("No video files found", movie.getFiles().isEmpty()); mf = movie.getFirstFile(); assertTrue(StringUtils.isNotBlank(mf.getPlot(1))); String plotStart = "Chaque année depuis quarante-quatre ans, le jour de son anniversaire, le président d'un "; assertNotNull(mf.getPlot(0)); assertTrue("Invalid plot length: " + mf.getPlot(1), mf.getPlot(1).length() >= plotStart.length()); assertEquals(plotStart, mf.getPlot(1).substring(0, plotStart.length())); }