diff --git a/source/net/filebot/Settings.java b/source/net/filebot/Settings.java index e8427593..4cd2397e 100644 --- a/source/net/filebot/Settings.java +++ b/source/net/filebot/Settings.java @@ -12,6 +12,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; +import java.net.URI; import java.util.Locale; import java.util.ResourceBundle; import java.util.logging.Level; @@ -52,6 +53,10 @@ public final class Settings { return ResourceBundle.getBundle(Settings.class.getName(), Locale.ROOT).getString(key); } + public static URI getApiResource(String resource) { + return URI.create("https://api.filebot.net/" + getApplicationRevisionNumber() + "/" + resource); + } + public static String getApiKey(String name) { return getApplicationProperty("apikey." + name); } diff --git a/source/net/filebot/Settings.properties b/source/net/filebot/Settings.properties index 7fc43eda..62dfdb9b 100644 --- a/source/net/filebot/Settings.properties +++ b/source/net/filebot/Settings.properties @@ -4,7 +4,6 @@ application.revision: @{revision} update.url: @{update.url} -github.stable: @{github.stable} github.master: @{github.master} link.mas: @{link.mas} diff --git a/source/net/filebot/cli/ScriptSource.java b/source/net/filebot/cli/ScriptSource.java index d48f0caf..65650ed3 100644 --- a/source/net/filebot/cli/ScriptSource.java +++ b/source/net/filebot/cli/ScriptSource.java @@ -27,12 +27,12 @@ public enum ScriptSource { @Override public ScriptProvider getScriptProvider(String input) throws Exception { - URI resource = new URI(getApplicationProperty("github.stable")); - Resource bundle = getCache().bytes(resource, URI::toURL, XZInputStream::new).expire(Cache.ONE_WEEK); + Resource bundle = getCache().bytes("fn", s -> { + return getApiResource("script/" + s + ".jar.xz").toURL(); + }, XZInputStream::new).expire(Cache.ONE_WEEK); return new ScriptBundle(bundle, getClass().getResourceAsStream("repository.cer")); } - }, GITHUB_MASTER { @@ -49,7 +49,6 @@ public enum ScriptSource { // NOTE: GitHub only supports If-None-Match (If-Modified-Since is ignored) return n -> getCache().text(n, s -> parent.resolve(s + ".groovy").toURL()).fetch(fetchIfNoneMatch(url -> n, getCache())).expire(Cache.ONE_DAY).get(); } - }, INLINE_GROOVY { @@ -63,7 +62,6 @@ public enum ScriptSource { public ScriptProvider getScriptProvider(String input) throws Exception { return g -> g; } - }, REMOTE_URL { @@ -92,7 +90,6 @@ public enum ScriptSource { return n -> getCache().text(n, s -> parent.resolve(s + ".groovy").toURL()).expire(Duration.ZERO).get(); } - }, LOCAL_FILE { @@ -116,7 +113,6 @@ public enum ScriptSource { return f -> readTextFile(new File(base, f + ".groovy")); } - }; public abstract String accept(String input); diff --git a/source/net/filebot/media/ReleaseInfo.java b/source/net/filebot/media/ReleaseInfo.java index f34715fd..9d1676f4 100644 --- a/source/net/filebot/media/ReleaseInfo.java +++ b/source/net/filebot/media/ReleaseInfo.java @@ -15,7 +15,6 @@ import static net.filebot.util.StringUtilities.*; import java.io.File; import java.io.FileFilter; -import java.net.URL; import java.nio.ByteBuffer; import java.text.Collator; import java.text.Normalizer; @@ -45,7 +44,6 @@ import net.filebot.CacheType; import net.filebot.Resource; import net.filebot.util.FileUtilities.RegexFindFilter; import net.filebot.util.FileUtilities.RegexMatchFilter; -import net.filebot.util.SystemProperty; import net.filebot.web.AnimeLists; import net.filebot.web.Movie; import net.filebot.web.SearchResult; @@ -444,7 +442,7 @@ public class ReleaseInfo { return PIPE.split(tags); } - private final Resource> seriesMappings = resource("url.series-mappings", Cache.ONE_WEEK, Function.identity(), String[]::new).transform(lines -> { + private final Resource> seriesMappings = resource("series-mappings.txt", Cache.ONE_WEEK, Function.identity(), String[]::new).transform(lines -> { Map map = new LinkedHashMap(lines.length); stream(lines).map(s -> TAB.split(s, 2)).filter(v -> v.length == 2).forEach(v -> { Pattern pattern = compile("(? animeListModel = resource("url.anime-list", Cache.ONE_WEEK, bytes -> { + private final Resource animeListModel = resource("anime-list.xml", Cache.ONE_WEEK, bytes -> { return AnimeLists.unmarshal(bytes, AnimeLists.Model.class); }).memoize(); - private final Resource releaseGroup = lines("url.release-groups", Cache.ONE_WEEK); - private final Resource queryBlacklist = lines("url.query-blacklist", Cache.ONE_WEEK); + private final Resource releaseGroup = lines("release-groups.txt", Cache.ONE_WEEK); + private final Resource queryBlacklist = lines("query-blacklist.txt", Cache.ONE_WEEK); - private final Resource tvdbIndex = tsv("url.thetvdb-index", Cache.ONE_WEEK, this::parseSeries, SearchResult[]::new); - private final Resource anidbIndex = tsv("url.anidb-index", Cache.ONE_WEEK, this::parseSeries, SearchResult[]::new); + private final Resource tvdbIndex = tsv("thetvdb.txt", Cache.ONE_WEEK, this::parseSeries, SearchResult[]::new); + private final Resource anidbIndex = tsv("anidb.txt", Cache.ONE_WEEK, this::parseSeries, SearchResult[]::new); - private final Resource movieIndex = tsv("url.movie-list", Cache.ONE_MONTH, this::parseMovie, Movie[]::new); - private final Resource osdbIndex = tsv("url.osdb-index", Cache.ONE_MONTH, this::parseSubtitle, SubtitleSearchResult[]::new); - - private final SystemProperty refreshDuration = SystemProperty.of("url.refresh", Duration::parse); + private final Resource movieIndex = tsv("moviedb.txt", Cache.ONE_MONTH, this::parseMovie, Movie[]::new); + private final Resource osdbIndex = tsv("osdb.txt", Cache.ONE_MONTH, this::parseSubtitle, SubtitleSearchResult[]::new); private SearchResult parseSeries(String[] v) { int id = parseInt(v[0]); @@ -512,7 +508,7 @@ public class ReleaseInfo { protected Resource resource(String name, Duration expirationTime, Function parse) { return () -> { Cache cache = Cache.getCache("data", CacheType.Persistent); - byte[] bytes = cache.bytes(name, n -> new URL(getProperty(n)), XZInputStream::new).expire(refreshDuration.optional().orElse(expirationTime)).get(); + byte[] bytes = cache.bytes(name, n -> getApiResource("data/" + n + ".xz").toURL(), XZInputStream::new).expire(expirationTime).get(); return parse.apply(bytes); }; } diff --git a/source/net/filebot/media/ReleaseInfo.properties b/source/net/filebot/media/ReleaseInfo.properties index c4a83a9a..16d53fb0 100644 --- a/source/net/filebot/media/ReleaseInfo.properties +++ b/source/net/filebot/media/ReleaseInfo.properties @@ -25,30 +25,6 @@ pattern.clutter.types: [.](jpg|jpeg|png|gif|ico|nfo|info|xml|htm|html|log|m3u|cu # only files smaller than 150 MB may be considered clutter number.clutter.maxfilesize: 150000000 -# known release group names -url.release-groups: @{url.data}/release-groups.txt.xz - -# blacklisted terms that will be ignored -url.query-blacklist: @{url.data}/query-blacklist.txt.xz - -# list of patterns directly matching files to series names -url.series-mappings: @{url.data}/series-mappings.txt.xz - -# list of all movies (id, name, year) -url.movie-list: @{url.data}/moviedb.txt.xz - -# TheTVDB index -url.thetvdb-index: @{url.data}/thetvdb.txt.xz - -# AniDB index -url.anidb-index: @{url.data}/anidb.txt.xz - -# OpenSubtitles index -url.osdb-index: @{url.data}/osdb.txt.xz - -# Anime List mappings -url.anime-list: @{url.data}/anime-list.xml.xz - # disk folder matcher pattern.diskfolder.entry: BDMV|HVDVD_TS|VIDEO_TS|AUDIO_TS|VCD|MovieObject.bdmv|VIDEO_TS.VOB|VTS_[0-9]+_[0-9]+.VOB diff --git a/source/net/filebot/similarity/EpisodeMetrics.java b/source/net/filebot/similarity/EpisodeMetrics.java index 102676ae..e5cc9c1a 100644 --- a/source/net/filebot/similarity/EpisodeMetrics.java +++ b/source/net/filebot/similarity/EpisodeMetrics.java @@ -5,7 +5,6 @@ import static java.util.Collections.*; import static java.util.regex.Pattern.*; import static java.util.stream.Collectors.*; import static net.filebot.Logging.*; -import static net.filebot.MediaTypes.*; import static net.filebot.media.MediaDetection.*; import static net.filebot.media.XattrMetaInfo.*; import static net.filebot.similarity.Normalization.*;