Browse Source

Use per-revision FileBot API

master
Reinhard Pointner 4 years ago
parent
commit
e3733c2d36
  1. 5
      source/net/filebot/Settings.java
  2. 1
      source/net/filebot/Settings.properties
  3. 10
      source/net/filebot/cli/ScriptSource.java
  4. 22
      source/net/filebot/media/ReleaseInfo.java
  5. 24
      source/net/filebot/media/ReleaseInfo.properties
  6. 1
      source/net/filebot/similarity/EpisodeMetrics.java

5
source/net/filebot/Settings.java

@ -12,6 +12,7 @@ import java.io.FileInputStream; @@ -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 { @@ -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);
}

1
source/net/filebot/Settings.properties

@ -4,7 +4,6 @@ application.revision: @{revision} @@ -4,7 +4,6 @@ application.revision: @{revision}
update.url: @{update.url}
github.stable: @{github.stable}
github.master: @{github.master}
link.mas: @{link.mas}

10
source/net/filebot/cli/ScriptSource.java

@ -27,12 +27,12 @@ public enum ScriptSource { @@ -27,12 +27,12 @@ public enum ScriptSource {
@Override
public ScriptProvider getScriptProvider(String input) throws Exception {
URI resource = new URI(getApplicationProperty("github.stable"));
Resource<byte[]> bundle = getCache().bytes(resource, URI::toURL, XZInputStream::new).expire(Cache.ONE_WEEK);
Resource<byte[]> 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 { @@ -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 { @@ -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 { @@ -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 { @@ -116,7 +113,6 @@ public enum ScriptSource {
return f -> readTextFile(new File(base, f + ".groovy"));
}
};
public abstract String accept(String input);

22
source/net/filebot/media/ReleaseInfo.java

@ -15,7 +15,6 @@ import static net.filebot.util.StringUtilities.*; @@ -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; @@ -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 { @@ -444,7 +442,7 @@ public class ReleaseInfo {
return PIPE.split(tags);
}
private final Resource<Map<Pattern, String>> seriesMappings = resource("url.series-mappings", Cache.ONE_WEEK, Function.identity(), String[]::new).transform(lines -> {
private final Resource<Map<Pattern, String>> seriesMappings = resource("series-mappings.txt", Cache.ONE_WEEK, Function.identity(), String[]::new).transform(lines -> {
Map<Pattern, String> map = new LinkedHashMap<Pattern, String>(lines.length);
stream(lines).map(s -> TAB.split(s, 2)).filter(v -> v.length == 2).forEach(v -> {
Pattern pattern = compile("(?<!\\p{Alnum})(" + v[0] + ")(?!\\p{Alnum})", CASE_INSENSITIVE);
@ -453,20 +451,18 @@ public class ReleaseInfo { @@ -453,20 +451,18 @@ public class ReleaseInfo {
return unmodifiableMap(map);
}).memoize();
private final Resource<AnimeLists.Model> animeListModel = resource("url.anime-list", Cache.ONE_WEEK, bytes -> {
private final Resource<AnimeLists.Model> animeListModel = resource("anime-list.xml", Cache.ONE_WEEK, bytes -> {
return AnimeLists.unmarshal(bytes, AnimeLists.Model.class);
}).memoize();
private final Resource<String[]> releaseGroup = lines("url.release-groups", Cache.ONE_WEEK);
private final Resource<String[]> queryBlacklist = lines("url.query-blacklist", Cache.ONE_WEEK);
private final Resource<String[]> releaseGroup = lines("release-groups.txt", Cache.ONE_WEEK);
private final Resource<String[]> queryBlacklist = lines("query-blacklist.txt", Cache.ONE_WEEK);
private final Resource<SearchResult[]> tvdbIndex = tsv("url.thetvdb-index", Cache.ONE_WEEK, this::parseSeries, SearchResult[]::new);
private final Resource<SearchResult[]> anidbIndex = tsv("url.anidb-index", Cache.ONE_WEEK, this::parseSeries, SearchResult[]::new);
private final Resource<SearchResult[]> tvdbIndex = tsv("thetvdb.txt", Cache.ONE_WEEK, this::parseSeries, SearchResult[]::new);
private final Resource<SearchResult[]> anidbIndex = tsv("anidb.txt", Cache.ONE_WEEK, this::parseSeries, SearchResult[]::new);
private final Resource<Movie[]> movieIndex = tsv("url.movie-list", Cache.ONE_MONTH, this::parseMovie, Movie[]::new);
private final Resource<SubtitleSearchResult[]> osdbIndex = tsv("url.osdb-index", Cache.ONE_MONTH, this::parseSubtitle, SubtitleSearchResult[]::new);
private final SystemProperty<Duration> refreshDuration = SystemProperty.of("url.refresh", Duration::parse);
private final Resource<Movie[]> movieIndex = tsv("moviedb.txt", Cache.ONE_MONTH, this::parseMovie, Movie[]::new);
private final Resource<SubtitleSearchResult[]> 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 { @@ -512,7 +508,7 @@ public class ReleaseInfo {
protected <A> Resource<A> resource(String name, Duration expirationTime, Function<byte[], A> 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);
};
}

24
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 @@ -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

1
source/net/filebot/similarity/EpisodeMetrics.java

@ -5,7 +5,6 @@ import static java.util.Collections.*; @@ -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.*;

Loading…
Cancel
Save