mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-15 22:05:00 -05:00
* improved series lookup
This commit is contained in:
parent
25742ba566
commit
3326a30735
@ -196,7 +196,7 @@ public class MediaDetection {
|
||||
Set<String> filenames = new LinkedHashSet<String>();
|
||||
for (File f : files) {
|
||||
for (int i = 0; i < 3 && f != null; i++, f = f.getParentFile()) {
|
||||
(i == 0 ? filenames : folders).add(f.getName());
|
||||
(i == 0 ? filenames : folders).add(normalizeBrackets(f.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -112,19 +113,15 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||
// allow only one select dialog at a time
|
||||
synchronized (this) {
|
||||
synchronized (selectionMemory) {
|
||||
SearchResult selection = selectionMemory.get(query);
|
||||
if (selection != null) {
|
||||
return selection;
|
||||
if (selectionMemory.containsKey(query)) {
|
||||
return selectionMemory.get(query);
|
||||
}
|
||||
|
||||
SwingUtilities.invokeAndWait(showSelectDialog);
|
||||
|
||||
// cache selected value
|
||||
selection = showSelectDialog.get();
|
||||
if (selection != null) {
|
||||
selectionMemory.put(query, selection);
|
||||
}
|
||||
return selection;
|
||||
selectionMemory.put(query, showSelectDialog.get());
|
||||
return showSelectDialog.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -290,7 +287,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||
if (input.size() > 0) {
|
||||
// only allow one fetch session at a time so later requests can make use of cached results
|
||||
synchronized (providerLock) {
|
||||
episodes = fetchEpisodeSet(input, sortOrder, locale, selectionMemory, parent);
|
||||
episodes = fetchEpisodeSet(input, sortOrder, locale, new HashMap<String, SearchResult>(), parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,6 +169,7 @@ public class AnidbClient extends AbstractEpisodeListProvider {
|
||||
|
||||
Map<Integer, String> primaryTitleMap = new HashMap<Integer, String>();
|
||||
Map<Integer, Map<String, String>> officialTitleMap = new HashMap<Integer, Map<String, String>>();
|
||||
Map<Integer, Map<String, String>> synonymsTitleMap = new HashMap<Integer, Map<String, String>>();
|
||||
|
||||
// fetch data
|
||||
Scanner scanner = new Scanner(new GZIPInputStream(url.openStream()), "UTF-8");
|
||||
@ -185,11 +186,12 @@ public class AnidbClient extends AbstractEpisodeListProvider {
|
||||
|
||||
if (type.equals("1")) {
|
||||
primaryTitleMap.put(aid, title);
|
||||
} else if (type.equals("4")) {
|
||||
Map<String, String> languageTitleMap = officialTitleMap.get(aid);
|
||||
} else if (type.equals("2") || type.equals("4")) {
|
||||
Map<Integer, Map<String, String>> titleMap = (type.equals("4") ? officialTitleMap : synonymsTitleMap);
|
||||
Map<String, String> languageTitleMap = titleMap.get(aid);
|
||||
if (languageTitleMap == null) {
|
||||
languageTitleMap = new HashMap<String, String>();
|
||||
officialTitleMap.put(aid, languageTitleMap);
|
||||
titleMap.put(aid, languageTitleMap);
|
||||
}
|
||||
|
||||
languageTitleMap.put(language, title);
|
||||
@ -204,7 +206,15 @@ public class AnidbClient extends AbstractEpisodeListProvider {
|
||||
anime = new ArrayList<AnidbSearchResult>(primaryTitleMap.size());
|
||||
|
||||
for (Entry<Integer, String> entry : primaryTitleMap.entrySet()) {
|
||||
anime.add(new AnidbSearchResult(entry.getKey(), entry.getValue(), officialTitleMap.get(entry.getKey())));
|
||||
Map<String, String> localizedTitles = new HashMap<String, String>();
|
||||
if (synonymsTitleMap.containsKey(entry.getKey())) {
|
||||
localizedTitles.putAll(synonymsTitleMap.get(entry.getKey())); // use synonym as fallback
|
||||
}
|
||||
if (officialTitleMap.containsKey(entry.getKey())) {
|
||||
localizedTitles.putAll(officialTitleMap.get(entry.getKey())); // primarily use official title if available
|
||||
}
|
||||
|
||||
anime.add(new AnidbSearchResult(entry.getKey(), entry.getValue(), localizedTitles));
|
||||
}
|
||||
|
||||
// populate cache
|
||||
|
Loading…
Reference in New Issue
Block a user