mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-17 23:05:03 -05:00
* rewrite extended metadata lookup logic
This commit is contained in:
parent
ff33e970c7
commit
9a275b8f99
@ -557,34 +557,50 @@ public class MediaBindingBean {
|
||||
public synchronized AssociativeScriptObject getMetaInfo() {
|
||||
if (metaInfo == null) {
|
||||
try {
|
||||
if (infoObject instanceof Episode)
|
||||
metaInfo = WebServices.TheTVDB.getSeriesInfoByName(getEpisode().getSeriesName(), getEpisode().getLanguage() == null ? Locale.ENGLISH : getEpisode().getLanguage());
|
||||
if (infoObject instanceof Movie)
|
||||
if (infoObject instanceof Episode) {
|
||||
Episode episode = (Episode) infoObject;
|
||||
if (episode.getSeries() instanceof TheTVDBSearchResult) {
|
||||
metaInfo = WebServices.TheTVDB.getSeriesInfo((TheTVDBSearchResult) episode.getSeries(), episode.getLanguage() == null ? Locale.ENGLISH : episode.getLanguage());
|
||||
}
|
||||
} else if (infoObject instanceof Movie) {
|
||||
if (getMovie().getTmdbId() > 0) {
|
||||
metaInfo = WebServices.TheMovieDB.getMovieInfo(getMovie(), getMovie().getLanguage() == null ? Locale.ENGLISH : getMovie().getLanguage(), true);
|
||||
} else if (getMovie().getImdbId() > 0) {
|
||||
metaInfo = WebServices.OMDb.getMovieInfo(getMovie());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to retrieve metadata: " + infoObject, e);
|
||||
throw new RuntimeException("Failed to retrieve extended metadata: " + infoObject, e);
|
||||
}
|
||||
}
|
||||
|
||||
if (mediaInfo == null) {
|
||||
throw new UnsupportedOperationException("Extended metadata not available");
|
||||
}
|
||||
|
||||
return createMapBindings(new PropertyBindings(metaInfo, null));
|
||||
}
|
||||
|
||||
@Define("imdb")
|
||||
public synchronized AssociativeScriptObject getImdbApiInfo() {
|
||||
Object data = null;
|
||||
Object metaInfo = null;
|
||||
|
||||
try {
|
||||
if (infoObject instanceof Episode) {
|
||||
data = WebServices.OMDb.getMovieInfo(new Movie(getEpisode().getSeriesName(), getEpisode().getSeriesStartDate().getYear(), -1, -1));
|
||||
metaInfo = WebServices.OMDb.getMovieInfo(new Movie(getEpisode().getSeriesName(), getEpisode().getSeriesStartDate().getYear(), -1, -1));
|
||||
}
|
||||
if (infoObject instanceof Movie) {
|
||||
Movie m = getMovie();
|
||||
data = WebServices.OMDb.getMovieInfo(m.getImdbId() > 0 ? m : new Movie(null, -1, WebServices.TheMovieDB.getMovieInfo(getMovie(), Locale.ENGLISH, false).getImdbId(), -1));
|
||||
metaInfo = WebServices.OMDb.getMovieInfo(getMovie());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to retrieve metadata: " + infoObject, e);
|
||||
throw new RuntimeException("Failed to retrieve extended metadata: " + infoObject, e);
|
||||
}
|
||||
|
||||
return createMapBindings(new PropertyBindings(data, null));
|
||||
if (mediaInfo == null) {
|
||||
throw new UnsupportedOperationException("Extended metadata not available");
|
||||
}
|
||||
|
||||
return createMapBindings(new PropertyBindings(metaInfo, null));
|
||||
}
|
||||
|
||||
@Define("episodelist")
|
||||
|
@ -177,15 +177,9 @@ public class TMDbClient implements MovieIdentificationService {
|
||||
return getMovieInfo(String.valueOf(movie.getTmdbId()), locale, extendedInfo);
|
||||
} else if (movie.getImdbId() > 0) {
|
||||
return getMovieInfo(String.format("tt%07d", movie.getImdbId()), locale, extendedInfo);
|
||||
} else {
|
||||
for (Movie result : searchMovie(movie.getName(), locale)) {
|
||||
if (movie.getName().equalsIgnoreCase(result.getName()) && movie.getYear() == result.getYear()) {
|
||||
return getMovieInfo(String.valueOf(result.getTmdbId()), locale, extendedInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException | NullPointerException e) {
|
||||
Logger.getLogger(getClass().getName()).log(Level.WARNING, String.format("Movie data missing: %s [%d / %d]", movie, movie.getTmdbId(), movie.getImdbId()), e);
|
||||
Logger.getLogger(getClass().getName()).log(Level.WARNING, String.format("Movie data not found: %s [%d / %d]", movie, movie.getTmdbId(), movie.getImdbId()), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user