mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 16:28:51 -05:00
* better subtitle sanity
This commit is contained in:
parent
8b172432f9
commit
7b5e0f00f9
@ -4,6 +4,7 @@ package net.sourceforge.filebot.subtitle;
|
|||||||
|
|
||||||
import static java.lang.Math.*;
|
import static java.lang.Math.*;
|
||||||
import static net.sourceforge.filebot.MediaTypes.*;
|
import static net.sourceforge.filebot.MediaTypes.*;
|
||||||
|
import static net.sourceforge.filebot.media.MediaDetection.*;
|
||||||
import static net.sourceforge.filebot.similarity.EpisodeMetrics.*;
|
import static net.sourceforge.filebot.similarity.EpisodeMetrics.*;
|
||||||
import static net.sourceforge.filebot.similarity.Normalization.*;
|
import static net.sourceforge.filebot.similarity.Normalization.*;
|
||||||
import static net.sourceforge.tuned.FileUtilities.*;
|
import static net.sourceforge.tuned.FileUtilities.*;
|
||||||
@ -54,13 +55,13 @@ public final class SubtitleUtilities {
|
|||||||
@Override
|
@Override
|
||||||
public float getSimilarity(Object o1, Object o2) {
|
public float getSimilarity(Object o1, Object o2) {
|
||||||
float f = SeasonEpisode.getSimilarity(o1, o2);
|
float f = SeasonEpisode.getSimilarity(o1, o2);
|
||||||
if (f == 0)
|
if (f == 0 && (getEpisodeIdentifier(o1.toString(), true) == null) == (getEpisodeIdentifier(o2.toString(), true) == null)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
return f < 1 ? -1 : 1;
|
return f < 1 ? -1 : 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
SimilarityMetric sanity = new MetricCascade(FileSize, FileName, absoluteSeasonEpisode, AirDate, Title, Name);
|
SimilarityMetric sanity = new MetricCascade(absoluteSeasonEpisode, AirDate, new MetricAvg(SubstringSequence, Name));
|
||||||
|
|
||||||
// first match everything as best as possible, then filter possibly bad matches
|
// first match everything as best as possible, then filter possibly bad matches
|
||||||
Matcher<File, SubtitleDescriptor> matcher = new Matcher<File, SubtitleDescriptor>(files, subtitles, false, metrics);
|
Matcher<File, SubtitleDescriptor> matcher = new Matcher<File, SubtitleDescriptor>(files, subtitles, false, metrics);
|
||||||
@ -102,7 +103,7 @@ public final class SubtitleUtilities {
|
|||||||
|
|
||||||
// find probable matches using name similarity > threshold
|
// find probable matches using name similarity > threshold
|
||||||
for (SearchResult result : searchResults) {
|
for (SearchResult result : searchResults) {
|
||||||
if (metric.getSimilarity(query, removeTrailingBrackets(result.getName())) > 0.8f) {
|
if (metric.getSimilarity(query, removeTrailingBrackets(result.getName())) > 0.8f || result.getName().toLowerCase().startsWith(query.toLowerCase())) {
|
||||||
probableMatches.add(result);
|
probableMatches.add(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user