mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-22 07:48:52 -05:00
* adapt AnidbClient search query string to hide synonyms
* fixed bug that allowed the user to select a season-specific episodelist (e.g. Season 1) from anidb which is not supported * continue matching process even if we can't fetch episode-lists for one or more auto-detected names
This commit is contained in:
parent
fe37b816d1
commit
3162b3e7bc
@ -52,16 +52,16 @@ public class MediaTypes {
|
||||
}
|
||||
|
||||
|
||||
public FileFilter filter(String path) {
|
||||
return new ExtensionFileFilter(extensions(path));
|
||||
public FileFilter filter(String name) {
|
||||
return new ExtensionFileFilter(extensions(name));
|
||||
}
|
||||
|
||||
|
||||
public String[] extensions(String path) {
|
||||
public String[] extensions(String name) {
|
||||
List<String> extensions = new ArrayList<String>();
|
||||
|
||||
for (Type type : types) {
|
||||
if (type.name.startsWith(path)) {
|
||||
if (type.name.startsWith(name)) {
|
||||
addAll(extensions, type.extensions);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class Matcher<V, C> {
|
||||
private final List<V> values;
|
||||
private final List<C> candidates;
|
||||
|
||||
private final List<SimilarityMetric> metrics;
|
||||
private final SimilarityMetric[] metrics;
|
||||
|
||||
private final DisjointMatchCollection<V, C> disjointMatchCollection;
|
||||
|
||||
@ -29,7 +29,7 @@ public class Matcher<V, C> {
|
||||
this.values = new LinkedList<V>(values);
|
||||
this.candidates = new LinkedList<C>(candidates);
|
||||
|
||||
this.metrics = new ArrayList<SimilarityMetric>(metrics);
|
||||
this.metrics = metrics.toArray(new SimilarityMetric[0]);
|
||||
|
||||
this.disjointMatchCollection = new DisjointMatchCollection<V, C>();
|
||||
}
|
||||
@ -85,13 +85,13 @@ public class Matcher<V, C> {
|
||||
|
||||
|
||||
protected void deepMatch(Collection<Match<V, C>> possibleMatches, int level) throws InterruptedException {
|
||||
if (level >= metrics.size() || possibleMatches.isEmpty()) {
|
||||
if (level >= metrics.length || possibleMatches.isEmpty()) {
|
||||
// no further refinement possible
|
||||
disjointMatchCollection.addAll(possibleMatches);
|
||||
return;
|
||||
}
|
||||
|
||||
for (List<Match<V, C>> matchesWithEqualSimilarity : mapBySimilarity(possibleMatches, metrics.get(level)).values()) {
|
||||
for (List<Match<V, C>> matchesWithEqualSimilarity : mapBySimilarity(possibleMatches, metrics[level]).values()) {
|
||||
// some matches may already be unique
|
||||
List<Match<V, C>> disjointMatches = disjointMatches(matchesWithEqualSimilarity);
|
||||
|
||||
|
@ -24,13 +24,25 @@ class SeasonSpinnerModel extends SpinnerNumberModel {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getMinimum() {
|
||||
return (Integer) super.getMinimum();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getMaximum() {
|
||||
return (Integer) super.getMaximum();
|
||||
}
|
||||
|
||||
|
||||
public void spin(int steps) {
|
||||
int next = getSeason() + steps;
|
||||
|
||||
if (next < ALL_SEASONS)
|
||||
next = ALL_SEASONS;
|
||||
else if (next > MAX_VALUE)
|
||||
next = MAX_VALUE;
|
||||
if (next < getMinimum())
|
||||
next = getMinimum();
|
||||
else if (next > getMaximum())
|
||||
next = getMaximum();
|
||||
|
||||
setValue(next);
|
||||
}
|
||||
|
@ -37,10 +37,10 @@ class AutoFetchEpisodeListMatcher extends SwingWorker<List<Match<File, Episode>>
|
||||
|
||||
private final EpisodeListProvider provider;
|
||||
|
||||
private final Collection<SimilarityMetric> metrics;
|
||||
private final List<SimilarityMetric> metrics;
|
||||
|
||||
|
||||
public AutoFetchEpisodeListMatcher(EpisodeListProvider provider, List<File> files, Collection<SimilarityMetric> metrics) {
|
||||
public AutoFetchEpisodeListMatcher(EpisodeListProvider provider, Collection<File> files, Collection<SimilarityMetric> metrics) {
|
||||
this.provider = provider;
|
||||
this.files = new LinkedList<File>(files);
|
||||
this.metrics = new ArrayList<SimilarityMetric>(metrics);
|
||||
@ -80,14 +80,13 @@ class AutoFetchEpisodeListMatcher extends SwingWorker<List<Match<File, Episode>>
|
||||
public Collection<Episode> call() throws Exception {
|
||||
List<SearchResult> results = provider.search(seriesName);
|
||||
|
||||
if (results.isEmpty()) {
|
||||
throw new RuntimeException(String.format("'%s' has not been found.", seriesName));
|
||||
}
|
||||
|
||||
SearchResult selectedSearchResult = selectSearchResult(seriesName, results);
|
||||
|
||||
if (selectedSearchResult != null) {
|
||||
return provider.getEpisodeList(selectedSearchResult);
|
||||
// select search result
|
||||
if (results.size() > 0) {
|
||||
SearchResult selectedSearchResult = selectSearchResult(seriesName, results);
|
||||
|
||||
if (selectedSearchResult != null) {
|
||||
return provider.getEpisodeList(selectedSearchResult);
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
@ -97,7 +97,7 @@ class RenameListCellRenderer extends DefaultFancyListCellRenderer {
|
||||
String extension = FileUtilities.getExtension(file);
|
||||
|
||||
if (extension != null)
|
||||
return extension;
|
||||
return extension.toLowerCase();
|
||||
|
||||
// some file with no extension
|
||||
return "File";
|
||||
|
@ -96,7 +96,7 @@ public class RenameModel extends MatchModel<Object, File> {
|
||||
String extension = FileUtilities.getExtension(originalFile);
|
||||
|
||||
if (extension != null) {
|
||||
newName.append(".").append(extension);
|
||||
newName.append(".").append(extension.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ public class RenamePanel extends JComponent {
|
||||
add(matchButton, "split 2, flowy, sizegroupx button");
|
||||
add(renameButton, "gapy 30px, sizegroupx button");
|
||||
|
||||
add(new LoadingOverlayPane(namesList, namesList, "28px", "30px"), "grow, sizegroupx list");
|
||||
add(new LoadingOverlayPane(namesList, namesList, "32px", "30px"), "grow, sizegroupx list");
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,8 +44,7 @@ public class AnidbClient implements EpisodeListProvider {
|
||||
@Override
|
||||
public List<SearchResult> search(String query) throws IOException, SAXException {
|
||||
|
||||
// type=2 -> only TV Series
|
||||
URL searchUrl = new URL("http", host, "/perl-bin/animedb.pl?type=2&show=animelist&orderby.name=0.1&orderbar=0&noalias=1&do.search=Search&adb.search=" + URLEncoder.encode(query, "UTF-8"));
|
||||
URL searchUrl = new URL("http", host, "/perl-bin/animedb.pl?type.tvspecial=1&type.tvseries=1&type.ova=1&show=animelist&orderby.name=0.1&noalias=1&do.update=update&adb.search=" + URLEncoder.encode(query, "UTF-8"));
|
||||
|
||||
Document dom = getHtmlDocument(searchUrl);
|
||||
|
||||
|
@ -44,6 +44,23 @@ public class AnidbClientTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void searchHideSynonyms() throws Exception {
|
||||
final List<SearchResult> results = anidb.search("one piece");
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (SearchResult result : results) {
|
||||
if ("one piece".equalsIgnoreCase(result.getName())) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// must only occur once
|
||||
assertEquals(1, count, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void searchResultPageRedirect() throws Exception {
|
||||
List<SearchResult> results = anidb.search("twelve kingdoms");
|
||||
|
Loading…
Reference in New Issue
Block a user