mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 16:58:51 -05:00
* improved substring matching for instances like Doctor Who vs Doctor Who (2005), The Office vs The Office (US), etc
This commit is contained in:
parent
93d2e0f379
commit
1f0d9214fb
@ -5,6 +5,7 @@ package net.sourceforge.filebot.ui.rename;
|
|||||||
import static java.util.Collections.*;
|
import static java.util.Collections.*;
|
||||||
import static javax.swing.JOptionPane.*;
|
import static javax.swing.JOptionPane.*;
|
||||||
import static net.sourceforge.filebot.MediaTypes.*;
|
import static net.sourceforge.filebot.MediaTypes.*;
|
||||||
|
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
||||||
import static net.sourceforge.tuned.FileUtilities.*;
|
import static net.sourceforge.tuned.FileUtilities.*;
|
||||||
import static net.sourceforge.tuned.ui.TunedUtilities.*;
|
import static net.sourceforge.tuned.ui.TunedUtilities.*;
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
|||||||
|
|
||||||
// find probable matches using name similarity > 0.9
|
// find probable matches using name similarity > 0.9
|
||||||
for (SearchResult result : searchResults) {
|
for (SearchResult result : searchResults) {
|
||||||
if (metric.getSimilarity(normalize(query), normalize(result.getName())) > 0.9) {
|
if (metric.getSimilarity(normalizeName(query), normalizeName(result.getName())) > 0.9) {
|
||||||
probableMatches.add(result);
|
probableMatches.add(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,9 +108,9 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String normalize(String value) {
|
private String normalizeName(String value) {
|
||||||
// remove trailing braces, e.g. Doctor Who (2005) -> doctor who
|
// remove trailing braces, e.g. Doctor Who (2005) -> doctor who
|
||||||
return value.replaceAll("[(]([^)]*)[)]", "").trim().toLowerCase();
|
return removeTrailingBraces(value).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ package net.sourceforge.filebot.ui.rename;
|
|||||||
|
|
||||||
import static java.lang.Math.*;
|
import static java.lang.Math.*;
|
||||||
import static net.sourceforge.filebot.hash.VerificationUtilities.*;
|
import static net.sourceforge.filebot.hash.VerificationUtilities.*;
|
||||||
|
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
||||||
import static net.sourceforge.tuned.FileUtilities.*;
|
import static net.sourceforge.tuned.FileUtilities.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -22,6 +23,7 @@ import net.sourceforge.filebot.similarity.SeasonEpisodeMatcher.SxE;
|
|||||||
import net.sourceforge.filebot.vfs.AbstractFile;
|
import net.sourceforge.filebot.vfs.AbstractFile;
|
||||||
import net.sourceforge.filebot.web.Date;
|
import net.sourceforge.filebot.web.Date;
|
||||||
import net.sourceforge.filebot.web.Episode;
|
import net.sourceforge.filebot.web.Episode;
|
||||||
|
import net.sourceforge.filebot.web.Movie;
|
||||||
|
|
||||||
|
|
||||||
public enum MatchSimilarityMetric implements SimilarityMetric {
|
public enum MatchSimilarityMetric implements SimilarityMetric {
|
||||||
@ -121,8 +123,8 @@ public enum MatchSimilarityMetric implements SimilarityMetric {
|
|||||||
|
|
||||||
protected String[] fields(Object object) {
|
protected String[] fields(Object object) {
|
||||||
if (object instanceof Episode) {
|
if (object instanceof Episode) {
|
||||||
Episode e = (Episode) object;
|
Episode episode = (Episode) object;
|
||||||
return new String[] { e.getSeriesName(), e.getTitle() };
|
return new String[] { removeTrailingBraces(episode.getSeriesName()), episode.getTitle() };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object instanceof File) {
|
if (object instanceof File) {
|
||||||
@ -130,6 +132,16 @@ public enum MatchSimilarityMetric implements SimilarityMetric {
|
|||||||
return new String[] { getName(file.getParentFile()), getName(file) };
|
return new String[] { getName(file.getParentFile()), getName(file) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (object instanceof Movie) {
|
||||||
|
Movie movie = (Movie) object;
|
||||||
|
return new String[] { movie.getName(), Integer.toString(movie.getYear()) };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (object instanceof AbstractFile) {
|
||||||
|
AbstractFile file = (AbstractFile) object;
|
||||||
|
return new String[] { getNameWithoutExtension(file.getName()) };
|
||||||
|
}
|
||||||
|
|
||||||
return new String[] { object.toString() };
|
return new String[] { object.toString() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
package net.sourceforge.filebot.web;
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
import static net.sourceforge.filebot.web.EpisodeListUtilities.*;
|
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
package net.sourceforge.filebot.web;
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
import static net.sourceforge.filebot.web.EpisodeListUtilities.*;
|
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
||||||
import static net.sourceforge.filebot.web.WebRequest.*;
|
import static net.sourceforge.filebot.web.WebRequest.*;
|
||||||
import static net.sourceforge.tuned.XPathUtilities.*;
|
import static net.sourceforge.tuned.XPathUtilities.*;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
package net.sourceforge.filebot.web;
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
import static net.sourceforge.filebot.web.EpisodeListUtilities.*;
|
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
||||||
import static net.sourceforge.filebot.web.WebRequest.*;
|
import static net.sourceforge.filebot.web.WebRequest.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
package net.sourceforge.filebot.web;
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
import static net.sourceforge.filebot.web.EpisodeListUtilities.*;
|
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
||||||
import static net.sourceforge.filebot.web.WebRequest.*;
|
import static net.sourceforge.filebot.web.WebRequest.*;
|
||||||
import static net.sourceforge.tuned.XPathUtilities.*;
|
import static net.sourceforge.tuned.XPathUtilities.*;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
package net.sourceforge.filebot.web;
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
import static net.sourceforge.filebot.web.EpisodeListUtilities.*;
|
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
||||||
import static net.sourceforge.filebot.web.WebRequest.*;
|
import static net.sourceforge.filebot.web.WebRequest.*;
|
||||||
import static net.sourceforge.tuned.XPathUtilities.*;
|
import static net.sourceforge.tuned.XPathUtilities.*;
|
||||||
|
|
||||||
|
@ -37,11 +37,6 @@ public final class StringUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isNullOrEmpty(String value) {
|
|
||||||
return value == null || value.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy constructor to prevent instantiation.
|
* Dummy constructor to prevent instantiation.
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +12,7 @@ AiRWAVES
|
|||||||
ALLiANCE
|
ALLiANCE
|
||||||
ANiHLS
|
ANiHLS
|
||||||
ARiGOLD
|
ARiGOLD
|
||||||
|
ASAP
|
||||||
AW
|
AW
|
||||||
aWake
|
aWake
|
||||||
aXXo
|
aXXo
|
||||||
@ -72,6 +73,7 @@ DiVERSiTY
|
|||||||
DivXNL-Team
|
DivXNL-Team
|
||||||
DMT
|
DMT
|
||||||
DnB
|
DnB
|
||||||
|
DNL
|
||||||
DOT
|
DOT
|
||||||
DOWN
|
DOWN
|
||||||
ELECTRiC
|
ELECTRiC
|
||||||
@ -80,6 +82,7 @@ EnDoR
|
|||||||
ESiR
|
ESiR
|
||||||
ETM
|
ETM
|
||||||
EUHD
|
EUHD
|
||||||
|
EuReKA
|
||||||
ExtraTorrentRG
|
ExtraTorrentRG
|
||||||
FHM
|
FHM
|
||||||
FLAiTE
|
FLAiTE
|
||||||
@ -110,6 +113,7 @@ HDFiRE
|
|||||||
HDFL
|
HDFL
|
||||||
HDi
|
HDi
|
||||||
HDL
|
HDL
|
||||||
|
HDMaNiAcS
|
||||||
HDMI
|
HDMI
|
||||||
HDQ
|
HDQ
|
||||||
HDVD
|
HDVD
|
||||||
@ -140,6 +144,7 @@ JAVLiU
|
|||||||
k2
|
k2
|
||||||
KaKa
|
KaKa
|
||||||
KOENiG
|
KOENiG
|
||||||
|
KRaLiMaRKo
|
||||||
KYR
|
KYR
|
||||||
Larceny
|
Larceny
|
||||||
LEViTY
|
LEViTY
|
||||||
@ -262,6 +267,7 @@ VanRay
|
|||||||
VCDVaULT
|
VCDVaULT
|
||||||
ViNYL
|
ViNYL
|
||||||
ViSiON
|
ViSiON
|
||||||
|
ViSTA
|
||||||
VOA
|
VOA
|
||||||
VoMiT
|
VoMiT
|
||||||
VoX
|
VoX
|
||||||
|
Loading…
Reference in New Issue
Block a user