basic functionallity almost achieved
This commit is contained in:
parent
3ac6eb01cf
commit
f8d85a16ff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18939
response.json
18939
response.json
File diff suppressed because one or more lines are too long
@ -39,13 +39,17 @@ public class Common {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public static String regex(String fetchURL) throws Exception{ // Regexes off the start and end square braces returned by certain APIs?
|
public static String regexFetch(String fetchURL) throws Exception{ // Regexes off the start and end square braces returned by certain APIs?
|
||||||
String raw = rawFetch(fetchURL);
|
String raw = rawFetch(fetchURL);
|
||||||
raw = raw.substring(1, raw.length() - 1);
|
raw = raw.substring(1, raw.length() - 1);
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
public static String regex(String raw) throws Exception{ // Regexes off the start and end square braces returned by certain APIs?
|
||||||
|
raw = raw.substring(1, raw.length() - 1);
|
||||||
|
return raw;
|
||||||
|
}
|
||||||
public static String parse(String fetchURL, String keyToFetch) throws Exception{
|
public static String parse(String fetchURL, String keyToFetch) throws Exception{
|
||||||
String raw = regex(fetchURL);
|
String raw = regexFetch(fetchURL);
|
||||||
JSONTokener tokener = new JSONTokener(raw);
|
JSONTokener tokener = new JSONTokener(raw);
|
||||||
JSONObject object = new JSONObject(tokener);
|
JSONObject object = new JSONObject(tokener);
|
||||||
return object.getString(keyToFetch);
|
return object.getString(keyToFetch);
|
||||||
|
@ -1,10 +1,24 @@
|
|||||||
package com.calebfontenot.parsers;
|
package com.calebfontenot.parsers;
|
||||||
|
|
||||||
import com.calebfontenot.Common;
|
import com.calebfontenot.Common;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.json.JSONTokener;
|
||||||
|
|
||||||
public class Velocity {
|
public class Velocity {
|
||||||
public static final String MODRINTH_API_URL = "https://api.modrinth.com/v2";
|
public static final String MODRINTH_API_URL = "https://api.modrinth.com/v2";
|
||||||
public static void fetchVersions(String modID) throws Exception { // Fetch information about mod versions from the API.
|
public static void fetchVersions(String modID) throws Exception { // Fetch information about mod versions from the API.
|
||||||
System.out.println(Common.parse(MODRINTH_API_URL + "/project/" + modID + "/version", "id"));
|
String versions = Common.regexFetch(MODRINTH_API_URL + "/project/" + modID + "/version");
|
||||||
|
|
||||||
|
//while (true) {
|
||||||
|
JSONTokener tokener = new JSONTokener(versions);
|
||||||
|
JSONObject object = new JSONObject(tokener);
|
||||||
|
//System.out.println(object);
|
||||||
|
String files = Common.regex(object.getJSONArray("files").toString());
|
||||||
|
JSONTokener tokener2 = new JSONTokener(files);
|
||||||
|
JSONObject object2 = new JSONObject(tokener2);
|
||||||
|
System.out.println(object2.getString("url"));
|
||||||
|
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user