[update] PixabayStorage

This commit is contained in:
2020-01-16 22:13:52 +03:00
parent 3f4f192736
commit a4a33708a1

View File

@@ -11,6 +11,28 @@ typedef PixabayResponse = {
}>
}
enum PixabayCategory {
FASHION;
NATURE;
BACKGROUNDS;
SCIENCE;
EDUCATION;
PEOPLE;
FEELINGS;
RELIGION;
HEALTH;
PLACES;
ANIMALS;
INDUSTRY;
FOOD;
COMPUTER;
SPORTS;
TRANSPORTATION;
TRAVEL; BUILDINGS;
BUSINESS;
MUSIC;
}
@:provide class PixabayStorage extends SharedObjectStorage implements ISourceStorage {
private var key:String;
@@ -26,7 +48,7 @@ typedef PixabayResponse = {
return enabled && exists(type) ?
Promise.promise(read(type)) :
new JsonLoader<PixabayResponse>()
.GET('https://pixabay.com/api/?key=${key}&category=${type}')
.GET('https://pixabay.com/api/?key=${key}&q=${type}')
.then(function(result:PixabayResponse) {
var result = [for (item in result.hits) URL(item.largeImageURL)];
if (enabled) {