Skip to content

Commit

Permalink
handling uncompressed data files
Browse files Browse the repository at this point in the history
  • Loading branch information
bigoulours committed Mar 28, 2023
1 parent 88a8cf6 commit bc8c458
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dist/
cache/
lib/ivy/

*.properties
*.txt

*.cmd
Expand Down
2 changes: 1 addition & 1 deletion source/net/filebot/Settings.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# application settings
application.name: FileBot
application.version: 4.7.19.1
application.version: 4.7.19.2
application.revision: @{revision}

# application updates
Expand Down
18 changes: 11 additions & 7 deletions source/net/filebot/media/ReleaseInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public String[] getSubtitleCategoryTags() {
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("url.series-mappings", Cache.ONE_WEEK, Function.identity(), String[]::new, true).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);
Expand Down Expand Up @@ -469,19 +469,23 @@ private SubtitleSearchResult parseSubtitle(String[] v) {
}

protected Resource<String[]> lines(String name, Duration expirationTime) {
return resource(name, expirationTime, Function.identity(), String[]::new).memoize();
return resource(name, expirationTime, Function.identity(), String[]::new, true).memoize();
}

protected <A> Resource<A[]> tsv(String name, Duration expirationTime, Function<String[], A> parse, IntFunction<A[]> generator) {
return resource(name, expirationTime, s -> parse.apply(TAB.split(s)), generator).memoize();
return resource(name, expirationTime, s -> parse.apply(TAB.split(s)), generator, false).memoize();
}

protected <A> Resource<A[]> resource(String name, Duration expirationTime, Function<String, A> parse, IntFunction<A[]> generator) {
protected <A> Resource<A[]> resource(String name, Duration expirationTime, Function<String, A> parse, IntFunction<A[]> generator, Boolean txt) {
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();

// all data files are UTF-8 encoded XZ compressed text files
byte[] bytes;
if (txt) { // all data files are UTF-8 encoded text files
bytes = cache.bytes(name, n -> new URL(getProperty(n))).expire(refreshDuration.optional().orElse(expirationTime)).get();
}
else { // all data files are UTF-8 encoded XZ compressed text files
bytes = cache.bytes(name, n -> new URL(getProperty(n)), XZInputStream::new).expire(refreshDuration.optional().orElse(expirationTime)).get();
}
Stream<String> lines = NEWLINE.splitAsStream(UTF_8.decode(ByteBuffer.wrap(bytes)));

return lines.filter(s -> s.length() > 0).map(parse).filter(Objects::nonNull).toArray(generator);
Expand Down
6 changes: 3 additions & 3 deletions source/net/filebot/media/ReleaseInfo.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ pattern.clutter.excludes: (?<=[!\\-\\(\\[])(Sample|Trailer)|(Sample|Trailer)(?=[
number.clutter.maxfilesize: 150000000

# known release group names
url.release-groups: https://app.filebot.net/data/release-groups.txt.xz
url.release-groups: https://github.com/filebot/data/raw/master/release-groups.txt

# blacklisted terms that will be ignored
url.query-blacklist: https://app.filebot.net/data/query-blacklist.txt.xz
url.query-blacklist: https://github.com/filebot/data/raw/master/query-excludes.txt

# list of patterns directly matching files to series names
url.series-mappings: https://app.filebot.net/data/series-mappings.txt.xz
url.series-mappings: https://github.com/filebot/data/raw/master/series-mappings.txt

# list of all movies (id, name, year)
url.movie-list: https://app.filebot.net/data/moviedb.txt.xz
Expand Down

0 comments on commit bc8c458

Please sign in to comment.