public File GetFanartArtifactForTitle( Object mediaObject, MediaType mediaType, String mediaTitle, MediaArtifactType artifactType, String artifactTitle, Map<String, String> metadata, String centralFolder) { File art = null; art = FanartUtil.getCentralFanartArtifact( mediaType, mediaTitle, artifactType, artifactTitle, centralFolder, metadata); if (art == null || !art.exists()) { if (mediaType == MediaType.TV && metadata != null && metadata.get(FanartUtil.SEASON_NUMBER) != null) { // do a search without the season metadata art = FanartUtil.getCentralFanartArtifact( mediaType, mediaTitle, artifactType, artifactTitle, centralFolder, null); } } // if no matches, then find the first one if (art == null || !art.exists()) { File all[] = GetFanartArtifactsForTitle( mediaObject, mediaType, mediaTitle, artifactType, artifactTitle, metadata, centralFolder); if (!SageFanartUtil.isEmpty(all)) { art = all[0]; } } if (log.isDebugEnabled()) { log.debug( "GetFanartArtifactForTitle: MediaType: " + mediaType + "; MediaTitle: " + mediaTitle + "; ArtifactType: " + artifactType + "; ArtifactTitle: " + artifactTitle + "; Artifact: " + art + "; Season: " + getSeason(metadata) + "; MediaFile: " + mediaObject); } return art; }
/** * this is meant to return a subset of metadata properties that is useful for determining fanart * locations * * @param mediaType * @param mediaObject * @return */ private Map<String, String> getMetadata(MediaType mediaType, Object mediaObject) { if (mediaType == MediaType.TV) { Map<String, String> props = new HashMap<String, String>(); for (String key : new String[] {FanartUtil.SEASON_NUMBER, FanartUtil.EPISODE_NUMBER}) { String v = SageFanartUtil.GetMediaFileMetadata(mediaObject, key); if (!SageFanartUtil.isEmpty(v)) { props.put(key, v); } } return props; } return null; }