FanartTvPlugin { public FTMovie getMovieArtwork(int tmdbId, String imdbId) { String key; if (StringTools.isValidString(imdbId)) { key = CacheMemory.generateCacheKey(FANARTTV_PLUGIN_ID, imdbId); } else if (tmdbId > 0) { key = CacheMemory.generateCacheKey(FANARTTV_PLUGIN_ID, Integer.toString(tmdbId)); } else { return new FTMovie(); } FTMovie ftArtwork = (FTMovie) CacheMemory.getFromCache(key); if (ftArtwork == null || !ftArtwork.hasArtwork()) { try { if (StringTools.isValidString(imdbId)) { ftArtwork = ft.getMovieArtwork(imdbId); } else { ftArtwork = ft.getMovieArtwork(Integer.toString(tmdbId)); } if (ftArtwork != null && ftArtwork.hasArtwork()) { CacheMemory.addToCache(key, ftArtwork); } return ftArtwork; } catch (FanartTvException ex) { LOG.warn("Failed to get fanart information for IMDB ID: {} / TMDB ID: {}. Error: {}", imdbId, tmdbId, ex.getMessage(), ex); return new FTMovie(); } } return ftArtwork; } FanartTvPlugin(); boolean scan(Movie movie); boolean scan(Movie movie, final FTArtworkType artworkType); FTSeries getTvArtwork(int tvdbId); FTMovie getMovieArtwork(int tmdbId, String imdbId); static boolean isArtworkRequired(FTArtworkType requiredType); static boolean isArtworkRequired(String artworkType); static final String FANARTTV_PLUGIN_ID; }
@Test public void testGetMovieArtwork() { LOG.info("getMovieArtwork"); int tmdbId = 78; String imdbId = "tt0083658"; FTMovie result = ft.getMovieArtwork(tmdbId, null); assertEquals("Wrong result found", "Blade Runner", result.getName()); assertEquals("Incorrect IMDB ID", imdbId, result.getImdbId()); result = ft.getMovieArtwork(0, imdbId); assertEquals("Wrong result found", "Blade Runner", result.getName()); assertEquals("Incorrect TMDB ID", Integer.toString(tmdbId), result.getTmdbId()); }