forked from AntiCope/meteor-e621-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
literally just copy pasted most things from here: AntiCope#20 also changed the "contact repo"
- Loading branch information
1 parent
6331236
commit c64b94d
Showing
7 changed files
with
107 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package anticope.esixtwoone.sources; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
import meteordevelopment.meteorclient.utils.network.Http; | ||
|
||
public class DanBooru extends Source { | ||
|
||
private final String domain; | ||
private final int lastPage; | ||
|
||
public DanBooru(String domain, int lastPage) { | ||
this.domain = domain; | ||
this.lastPage = lastPage; | ||
} | ||
|
||
@Override | ||
public void reset() {} | ||
|
||
@Override | ||
public String randomImage(String filter, Size size) { | ||
String query = String.format("%s/posts.json?tags=%s&page=%d&format=json&limit=10", domain, filter, random.nextInt(0, lastPage)); | ||
JsonElement result = Http.get(query).sendJson(JsonElement.class); | ||
if (result == null) return null; | ||
|
||
if (result instanceof JsonArray array) { | ||
if (array.get(random.nextInt(0, Math.min(11, array.size()))) instanceof JsonObject post) { | ||
return switch (size) { | ||
case preview -> post.get("preview_file_url").getAsString(); | ||
case sample -> post.get("large_file_url").getAsString(); | ||
case file -> post.get("file_url").getAsString(); | ||
}; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package anticope.esixtwoone.sources; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
import meteordevelopment.meteorclient.utils.network.Http; | ||
|
||
public class NekosLife extends Source { | ||
|
||
private final String domain; | ||
|
||
public NekosLife(String domain) { | ||
this.domain = domain; | ||
} | ||
|
||
@Override | ||
public void reset() {} | ||
|
||
@Override | ||
public String randomImage(String filter, Size size) { | ||
String query = String.format("%s/api/v2/img/%s", domain, filter); | ||
JsonElement result = Http.get(query).sendJson(JsonElement.class); | ||
if (result == null) return null; | ||
|
||
if (result instanceof JsonObject object) { | ||
if (object.get("url") != null) { | ||
return object.get("url").getAsString(); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters