Refactor
This commit is contained in:
parent
95f2e38e9e
commit
0649850f31
|
@ -15,7 +15,7 @@
|
|||
<classpathentry kind="lib" path="lib/ivy/jar/miglayout-core.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/miglayout-swing.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/rsyntaxtextarea.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/xz.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/xz.jar" sourcepath="lib/ivy/source/xz.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/slf4j-api.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/commons-io.jar" sourcepath="lib/ivy/source/commons-io.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/jsoup.jar"/>
|
||||
|
|
5
.project
5
.project
|
@ -15,6 +15,11 @@
|
|||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>filebot-data</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/filebot-data</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>filebot-plugins</name>
|
||||
<type>2</type>
|
||||
|
|
|
@ -82,7 +82,7 @@ public class MediaDetection {
|
|||
} catch (Exception e) {
|
||||
debug.log(Level.SEVERE, "Unable to access clutter file filter: " + e.getMessage(), e);
|
||||
}
|
||||
return ((File f) -> false);
|
||||
return f -> false;
|
||||
}
|
||||
|
||||
public static boolean isDiskFolder(File folder) {
|
||||
|
@ -942,7 +942,7 @@ public class MediaDetection {
|
|||
querySet = getUniqueQuerySet(emptySet(), stripBlacklistedTerms(querySet));
|
||||
|
||||
// DEBUG
|
||||
debug.finest(format("Query %s => %s", queryLookupService.getName(), querySet));
|
||||
debug.finest(format("Query [%s] => %s", queryLookupService.getName(), querySet));
|
||||
|
||||
final Map<Movie, Float> probabilityMap = new LinkedHashMap<Movie, Float>();
|
||||
final SimilarityMetric metric = getMovieMatchMetric();
|
||||
|
|
|
@ -38,17 +38,18 @@ import java.util.function.IntFunction;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.tukaani.xz.XZInputStream;
|
||||
|
||||
import net.filebot.Cache;
|
||||
import net.filebot.CacheType;
|
||||
import net.filebot.Resource;
|
||||
import net.filebot.util.FileUtilities.RegexFileFilter;
|
||||
import net.filebot.util.SystemProperty;
|
||||
import net.filebot.web.AnidbSearchResult;
|
||||
import net.filebot.web.Movie;
|
||||
import net.filebot.web.SubtitleSearchResult;
|
||||
import net.filebot.web.TheTVDBSearchResult;
|
||||
|
||||
import org.tukaani.xz.XZInputStream;
|
||||
|
||||
public class ReleaseInfo {
|
||||
|
||||
private String[] videoSources;
|
||||
|
@ -411,6 +412,8 @@ public class ReleaseInfo {
|
|||
protected final Resource<Movie[]> movieIndex = tsv("url.movie-list", Cache.ONE_MONTH, this::parseMovie, Movie[]::new);
|
||||
protected final Resource<SubtitleSearchResult[]> osdbIndex = tsv("url.osdb-index", Cache.ONE_MONTH, this::parseSubtitle, SubtitleSearchResult[]::new);
|
||||
|
||||
protected final SystemProperty<Duration> refreshDuration = new SystemProperty<Duration>("url.refresh", Duration::parse, null);
|
||||
|
||||
private TheTVDBSearchResult parseSeries(String[] v) {
|
||||
int id = parseInt(v[0]);
|
||||
String name = v[1];
|
||||
|
@ -455,7 +458,7 @@ public class ReleaseInfo {
|
|||
protected <A> Resource<A[]> resource(String name, Duration expirationTime, Function<String, A> parse, IntFunction<A[]> generator) {
|
||||
return () -> {
|
||||
Cache cache = Cache.getCache("data", CacheType.Persistent);
|
||||
byte[] bytes = cache.bytes(name, n -> new URL(getProperty(n))).expire(expirationTime).get();
|
||||
byte[] bytes = cache.bytes(name, n -> new URL(getProperty(n))).expire(refreshDuration.orElse(expirationTime)).get();
|
||||
|
||||
// all data file are xz compressed
|
||||
try (BufferedReader text = new BufferedReader(new InputStreamReader(new XZInputStream(new ByteArrayInputStream(bytes)), UTF_8))) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.awt.event.ActionEvent;
|
|||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
|
@ -104,13 +105,15 @@ public class SelectDialog<T> extends JDialog {
|
|||
|
||||
protected void configureValue(JComponent render, Object value) {
|
||||
if (value instanceof SearchResult) {
|
||||
render.setToolTipText(getSearchResultPopup((SearchResult) value));
|
||||
render.setToolTipText(getTooltipText((SearchResult) value));
|
||||
} else if (value instanceof File) {
|
||||
render.setToolTipText(((File) value).getAbsolutePath());
|
||||
} else {
|
||||
render.setToolTipText(null);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getSearchResultPopup(SearchResult item) {
|
||||
protected String getTooltipText(SearchResult item) {
|
||||
StringBuilder html = new StringBuilder(64);
|
||||
html.append("<html><b>").append(escapeHTML(item.toString())).append("</b><br>");
|
||||
String[] names = item.getAliasNames();
|
||||
|
|
|
@ -5,7 +5,9 @@ import static net.filebot.Logging.*;
|
|||
import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SystemProperty<T> {
|
||||
import net.filebot.Resource;
|
||||
|
||||
public class SystemProperty<T> implements Resource<T> {
|
||||
|
||||
public static <T> SystemProperty<T> of(String key, Function<String, T> valueFunction, T defaultValue) {
|
||||
return new SystemProperty<T>(key, valueFunction, defaultValue);
|
||||
|
@ -39,6 +41,11 @@ public class SystemProperty<T> {
|
|||
return defaultValue;
|
||||
}
|
||||
|
||||
public T orElse(T other) {
|
||||
T value = get();
|
||||
return value != null ? value : other;
|
||||
}
|
||||
|
||||
public void set(T value) {
|
||||
System.setProperty(key, value.toString());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue