diff --git a/source/net/sourceforge/filebot/MediaTypes.java b/source/net/sourceforge/filebot/MediaTypes.java index 97bc652d..aa4932ca 100644 --- a/source/net/sourceforge/filebot/MediaTypes.java +++ b/source/net/sourceforge/filebot/MediaTypes.java @@ -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 extensions = new ArrayList(); for (Type type : types) { - if (type.name.startsWith(path)) { + if (type.name.startsWith(name)) { addAll(extensions, type.extensions); } } diff --git a/source/net/sourceforge/filebot/similarity/Matcher.java b/source/net/sourceforge/filebot/similarity/Matcher.java index e6afb3c4..23afa90c 100644 --- a/source/net/sourceforge/filebot/similarity/Matcher.java +++ b/source/net/sourceforge/filebot/similarity/Matcher.java @@ -20,7 +20,7 @@ public class Matcher { private final List values; private final List candidates; - private final List metrics; + private final SimilarityMetric[] metrics; private final DisjointMatchCollection disjointMatchCollection; @@ -29,7 +29,7 @@ public class Matcher { this.values = new LinkedList(values); this.candidates = new LinkedList(candidates); - this.metrics = new ArrayList(metrics); + this.metrics = metrics.toArray(new SimilarityMetric[0]); this.disjointMatchCollection = new DisjointMatchCollection(); } @@ -85,13 +85,13 @@ public class Matcher { protected void deepMatch(Collection> 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> matchesWithEqualSimilarity : mapBySimilarity(possibleMatches, metrics.get(level)).values()) { + for (List> matchesWithEqualSimilarity : mapBySimilarity(possibleMatches, metrics[level]).values()) { // some matches may already be unique List> disjointMatches = disjointMatches(matchesWithEqualSimilarity); diff --git a/source/net/sourceforge/filebot/ui/panel/episodelist/SeasonSpinnerModel.java b/source/net/sourceforge/filebot/ui/panel/episodelist/SeasonSpinnerModel.java index 80f28df7..76c89e60 100644 --- a/source/net/sourceforge/filebot/ui/panel/episodelist/SeasonSpinnerModel.java +++ b/source/net/sourceforge/filebot/ui/panel/episodelist/SeasonSpinnerModel.java @@ -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); } diff --git a/source/net/sourceforge/filebot/ui/panel/rename/AutoFetchEpisodeListMatcher.java b/source/net/sourceforge/filebot/ui/panel/rename/AutoFetchEpisodeListMatcher.java index dcb68d37..ffe90711 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/AutoFetchEpisodeListMatcher.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/AutoFetchEpisodeListMatcher.java @@ -37,10 +37,10 @@ class AutoFetchEpisodeListMatcher extends SwingWorker> private final EpisodeListProvider provider; - private final Collection metrics; + private final List metrics; - public AutoFetchEpisodeListMatcher(EpisodeListProvider provider, List files, Collection metrics) { + public AutoFetchEpisodeListMatcher(EpisodeListProvider provider, Collection files, Collection metrics) { this.provider = provider; this.files = new LinkedList(files); this.metrics = new ArrayList(metrics); @@ -80,14 +80,13 @@ class AutoFetchEpisodeListMatcher extends SwingWorker> public Collection call() throws Exception { List 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(); diff --git a/source/net/sourceforge/filebot/ui/panel/rename/RenameListCellRenderer.java b/source/net/sourceforge/filebot/ui/panel/rename/RenameListCellRenderer.java index 4c6a82fb..d2b09e4d 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/RenameListCellRenderer.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/RenameListCellRenderer.java @@ -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"; diff --git a/source/net/sourceforge/filebot/ui/panel/rename/RenameModel.java b/source/net/sourceforge/filebot/ui/panel/rename/RenameModel.java index 0ec03b81..9c5344c3 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/RenameModel.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/RenameModel.java @@ -96,7 +96,7 @@ public class RenameModel extends MatchModel { String extension = FileUtilities.getExtension(originalFile); if (extension != null) { - newName.append(".").append(extension); + newName.append(".").append(extension.toLowerCase()); } } diff --git a/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java b/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java index 83c1b885..298af4a9 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java @@ -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"); } diff --git a/source/net/sourceforge/filebot/web/AnidbClient.java b/source/net/sourceforge/filebot/web/AnidbClient.java index cbf5a793..af719524 100644 --- a/source/net/sourceforge/filebot/web/AnidbClient.java +++ b/source/net/sourceforge/filebot/web/AnidbClient.java @@ -44,8 +44,7 @@ public class AnidbClient implements EpisodeListProvider { @Override public List 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); diff --git a/test/net/sourceforge/filebot/web/AnidbClientTest.java b/test/net/sourceforge/filebot/web/AnidbClientTest.java index 49f2f115..f6853c5f 100644 --- a/test/net/sourceforge/filebot/web/AnidbClientTest.java +++ b/test/net/sourceforge/filebot/web/AnidbClientTest.java @@ -44,6 +44,23 @@ public class AnidbClientTest { } + @Test + public void searchHideSynonyms() throws Exception { + final List 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 results = anidb.search("twelve kingdoms");