mirror of
https://github.com/mitb-archive/filebot
synced 2025-01-11 13:58:16 -05:00
* cache series ratings internally for likely repeated usage
This commit is contained in:
parent
c506a22999
commit
ed30ae0159
@ -465,13 +465,24 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
return max(getRating(o1), getRating(o2)) >= 0.4 ? 1 : 0;
|
return max(getRating(o1), getRating(o2)) >= 0.4 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final Map<String, SeriesInfo> seriesInfoCache = new HashMap<String, SeriesInfo>();
|
||||||
|
|
||||||
|
|
||||||
public float getRating(Object o) {
|
public float getRating(Object o) {
|
||||||
if (o instanceof Episode) {
|
if (o instanceof Episode) {
|
||||||
try {
|
try {
|
||||||
SeriesInfo seriesInfo = WebServices.TheTVDB.getSeriesInfoByLocalIndex(((Episode) o).getSeriesName(), Locale.ENGLISH);
|
synchronized (seriesInfoCache) {
|
||||||
if (seriesInfo != null && seriesInfo.getRatingCount() >= 10) {
|
String n = ((Episode) o).getSeriesName();
|
||||||
return max(0, seriesInfo.getRating().floatValue());
|
|
||||||
|
SeriesInfo seriesInfo = seriesInfoCache.get(n);
|
||||||
|
if (seriesInfo == null && !seriesInfoCache.containsKey(n)) {
|
||||||
|
seriesInfo = WebServices.TheTVDB.getSeriesInfoByLocalIndex(((Episode) o).getSeriesName(), Locale.ENGLISH);
|
||||||
|
seriesInfoCache.put(n, seriesInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seriesInfo != null && seriesInfo.getRatingCount() >= 10) {
|
||||||
|
return max(0, seriesInfo.getRating().floatValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.getLogger(EpisodeMetrics.class.getName()).log(Level.WARNING, e.getMessage());
|
Logger.getLogger(EpisodeMetrics.class.getName()).log(Level.WARNING, e.getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user