mirror of
https://github.com/nadimkobeissi/mkbsd.git
synced 2024-12-22 18:55:33 +00:00
move to java 23
This commit is contained in:
parent
c15fb9df4d
commit
40fcc66c21
33
mkbsd.java
33
mkbsd.java
|
@ -1,12 +1,12 @@
|
||||||
//DEPS com.fasterxml.jackson.core:jackson-databind:2.13.3
|
//DEPS com.fasterxml.jackson.core:jackson-databind:2.13.3
|
||||||
//DEPS com.fasterxml.jackson.core:jackson-core:2.13.3
|
//DEPS com.fasterxml.jackson.core:jackson-core:2.13.3
|
||||||
//DEPS com.fasterxml.jackson.core:jackson-annotations:2.13.3
|
//DEPS com.fasterxml.jackson.core:jackson-annotations:2.13.3
|
||||||
|
//JAVA 23+
|
||||||
|
//PREVIEW
|
||||||
import static java.lang.System.out;
|
import static java.lang.System.out;
|
||||||
import static java.nio.file.Files.*;
|
import static java.nio.file.Files.*;
|
||||||
import static java.util.concurrent.TimeUnit.*;
|
import static java.util.concurrent.TimeUnit.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
|
@ -18,19 +18,17 @@ import java.util.Map;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
public class mkbsd {
|
String URL = "https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~s";
|
||||||
|
HttpClient client = HttpClient.newHttpClient();
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
private static final String URL = "https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~s";
|
void main() throws Exception {
|
||||||
private static final HttpClient client = HttpClient.newHttpClient();
|
|
||||||
private static final ObjectMapper mapper = new ObjectMapper();
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
asciiArt();
|
asciiArt();
|
||||||
SECONDS.sleep(5);
|
SECONDS.sleep(5);
|
||||||
mainSync();
|
mainSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void mainSync() throws Exception {
|
void mainSync() throws Exception {
|
||||||
var jsonData = fetchJson(URL);
|
var jsonData = fetchJson(URL);
|
||||||
var data = (Map<String, Object>) jsonData.get("data");
|
var data = (Map<String, Object>) jsonData.get("data");
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
|
@ -62,9 +60,9 @@ public class mkbsd {
|
||||||
MILLISECONDS.sleep(250);
|
MILLISECONDS.sleep(250);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, Object> fetchJson(String url) throws Exception {
|
Map<String, Object> fetchJson(String url) throws Exception {
|
||||||
var request = HttpRequest.newBuilder()
|
var request = HttpRequest.newBuilder()
|
||||||
.uri(URI.create(url))
|
.uri(URI.create(url))
|
||||||
.build();
|
.build();
|
||||||
|
@ -74,9 +72,9 @@ public class mkbsd {
|
||||||
throw new RuntimeException("⛔ Failed to fetch JSON file: " + response.statusCode());
|
throw new RuntimeException("⛔ Failed to fetch JSON file: " + response.statusCode());
|
||||||
}
|
}
|
||||||
return mapper.readValue(response.body(), Map.class);
|
return mapper.readValue(response.body(), Map.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void downloadImage(String imageUrl, Path filePath) throws Exception {
|
void downloadImage(String imageUrl, Path filePath) throws Exception {
|
||||||
var request = HttpRequest.newBuilder()
|
var request = HttpRequest.newBuilder()
|
||||||
.uri(URI.create(imageUrl))
|
.uri(URI.create(imageUrl))
|
||||||
.build();
|
.build();
|
||||||
|
@ -86,11 +84,11 @@ public class mkbsd {
|
||||||
throw new RuntimeException("Failed to download image: " + response.statusCode());
|
throw new RuntimeException("Failed to download image: " + response.statusCode());
|
||||||
}
|
}
|
||||||
Files.write(filePath, response.body());
|
Files.write(filePath, response.body());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void asciiArt() {
|
void asciiArt() {
|
||||||
out.println("""
|
out.println("""
|
||||||
/$$ /$$ /$$ /$$ /$$$$$$$ /$$$$$$ /$$$$$$$
|
/$$ /$$ /$$ /$$ /$$$$$$$ /$$$$$$ /$$$$$$$
|
||||||
| $$$ /$$$| $$ /$$/| $$__ $$ /$$__ $$| $$__ $$
|
| $$$ /$$$| $$ /$$/| $$__ $$ /$$__ $$| $$__ $$
|
||||||
| $$$$ /$$$$| $$ /$$/ | $$ \\ $$| $$ \\__/| $$ \\ $$
|
| $$$$ /$$$$| $$ /$$/ | $$ \\ $$| $$ \\__/| $$ \\ $$
|
||||||
| $$ $$/$$ $$| $$$$$/ | $$$$$$$ | $$$$$$ | $$ | $$
|
| $$ $$/$$ $$| $$$$$/ | $$$$$$$ | $$$$$$ | $$ | $$
|
||||||
|
@ -100,5 +98,4 @@ public class mkbsd {
|
||||||
|__/ |__/|__/ \\__/|_______/ \\______/ |_______/""");
|
|__/ |__/|__/ \\__/|_______/ \\______/ |_______/""");
|
||||||
out.println("");
|
out.println("");
|
||||||
out.println("🤑 Starting downloads from your favorite sellout grifter's wallpaper app...");
|
out.println("🤑 Starting downloads from your favorite sellout grifter's wallpaper app...");
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue