aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/utility/WebAPI.java
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2023-12-12 20:26:28 -0800
committerPinapelz <yukais@pinapelz.com>2023-12-12 20:26:28 -0800
commit4fe931bf1f1eaa5783d5081b9beb2f47b35d0259 (patch)
tree7c988971ef677b6e5250912eead913e42c74308c /src/main/java/utility/WebAPI.java
parentff3ca04a6480e52bd13d09a3c8261b58d4abe724 (diff)
Add support for any .txt playlists via /play
- Have a newline delimited file of URLs of valid urls - Bot will attempt to queue up to MAX_LIMIT of them Signed-off-by: Pinapelz <yukais@pinapelz.com>
Diffstat (limited to 'src/main/java/utility/WebAPI.java')
-rw-r--r--src/main/java/utility/WebAPI.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/utility/WebAPI.java b/src/main/java/utility/WebAPI.java
new file mode 100644
index 0000000..9724760
--- /dev/null
+++ b/src/main/java/utility/WebAPI.java
@@ -0,0 +1,33 @@
+package utility;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+
+public class WebAPI {
+ public String[] getURLsFromSite(String urlString) {
+ try {
+ System.out.println("Getting URLs from " + urlString);
+ try (InputStream is = new URL(urlString).openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
+ StringBuilder sb = new StringBuilder();
+ int cb;
+ while ((cb = br.read()) != -1) {
+ sb.append((char) cb);
+ }
+ return sb.toString().split("\n");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ catch (Exception e){
+ System.out.println("Error: " + e.getMessage());
+ return null;
+ }
+ }
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage