mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-10 14:31:04 -04:00
parent
c547beb111
commit
a895b57067
@ -73,20 +73,24 @@ public enum AnimeLists {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static Cache getCache() {
|
protected static Cache getCache() {
|
||||||
return Cache.getCache("animelists", CacheType.Monthly);
|
return Cache.getCache("animelists", CacheType.Persistent);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static final Resource<Model> MODEL = Resource.lazy(AnimeLists::fetchModel);
|
protected static final Resource<Model> MODEL = Resource.lazy(AnimeLists::fetchModel);
|
||||||
|
|
||||||
protected static Model fetchModel() throws Exception {
|
protected static Model fetchModel() throws Exception {
|
||||||
|
return (Model) JAXBContext.newInstance(Model.class).createUnmarshaller().unmarshal(new ByteArrayInputStream(request("anime-list.xml")));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static byte[] request(String file) throws Exception {
|
||||||
|
// NOTE: GitHub only supports If-None-Match (If-Modified-Since is ignored)
|
||||||
Cache cache = getCache();
|
Cache cache = getCache();
|
||||||
|
|
||||||
// NOTE: GitHub only supports If-None-Match (If-Modified-Since is ignored)
|
return cache.bytes(file, AnimeLists::getResource).fetch(fetchIfNoneMatch(url -> file, cache)).expire(Cache.ONE_MONTH).get();
|
||||||
byte[] xml = cache.bytes("anime-list.xml", r -> {
|
}
|
||||||
return new URL("https://raw.githubusercontent.com/ScudLee/anime-lists/master/" + r);
|
|
||||||
}).fetch(fetchIfNoneMatch(URL::getFile, cache)).expire(Cache.ONE_MONTH).get();
|
|
||||||
|
|
||||||
return (Model) JAXBContext.newInstance(Model.class).createUnmarshaller().unmarshal(new ByteArrayInputStream(xml));
|
protected static URL getResource(String file) throws Exception {
|
||||||
|
return new URL("https://raw.githubusercontent.com/ScudLee/anime-lists/master/" + file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlRootElement(name = "anime-list")
|
@XmlRootElement(name = "anime-list")
|
||||||
|
@ -64,9 +64,14 @@ public enum Manami implements ArtworkProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static Object request(String file) throws Exception {
|
protected static Object request(String file) throws Exception {
|
||||||
return getCache().json(file, f -> {
|
// NOTE: GitHub only supports If-None-Match (If-Modified-Since is ignored)
|
||||||
return new URL("https://raw.githubusercontent.com/manami-project/anime-offline-database/master/" + f);
|
Cache cache = getCache();
|
||||||
}).fetch(fetchIfNoneMatch(URL::getPath, getCache())).expire(Cache.ONE_MONTH).get();
|
|
||||||
|
return cache.json(file, Manami::getResource).fetch(fetchIfNoneMatch(url -> file, cache)).expire(Cache.ONE_MONTH).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static URL getResource(String file) throws Exception {
|
||||||
|
return new URL("https://raw.githubusercontent.com/manami-project/anime-offline-database/master/" + file);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static final Resource<Object> database = Resource.lazy(() -> request("anime-offline-database.json"));
|
protected static final Resource<Object> database = Resource.lazy(() -> request("anime-offline-database.json"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user