This commit is contained in:
Celeste Madeline Samuel Nokto Dur Grossiord
2026-09-06 14:08:48 +02:00
parent 55add0db6a
commit 18a02484a4
39 changed files with 2065 additions and 1724 deletions
@@ -0,0 +1,45 @@
package org.sillyjirafe.uoapi.binds;
import org.json.JSONArray;
import org.json.JSONObject;
import org.sillyjirafe.uoapi.Api;
import org.sillyjirafe.uoapi.element;
import java.util.ArrayList;
import java.util.List;
public class CodeBergApi implements Api
{
public String getName()
{
return "CadeBergApi";
}
public String getURL(int page) {
return "https://codeberg.org/api/v1/repos/search?page=" + page;
}
public List<element> Parse(String jsonRaw) {
List<element> resultats = new ArrayList<>();
try {
JSONObject json = new JSONObject(jsonRaw);
JSONArray items = json.getJSONArray("items");
for (int i = 0; i < items.length(); i++) {
JSONObject repo = items.getJSONObject(i);
String titre = repo.getString("full_name");
String url = repo.getString("html_url");
String licence = repo.getJSONObject("license").getString("spdx_id");
resultats.add(new element(titre, url, licence, "codeberg", "code"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -0,0 +1,51 @@
package org.sillyjirafe.uoapi;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.sillyjirafe.uoapi.binds.CodeBergApi;
import org.sillyjirafe.uoapi.binds.GitHubApacheApi;
import org.sillyjirafe.uoapi.binds.GitHubLGPLApi;
import org.sillyjirafe.uoapi.binds.GitHubMITApi;
import org.sillyjirafe.uoapi.binds.OpenVerseAudiosApi;
import org.sillyjirafe.uoapi.binds.OpenVerseImagesApi;
public class Out {
List<Api> Apis = new ArrayList<>();
public List<String> PreOut()
{
Apis.add(new GitHubMITApi());
Apis.add(new GitHubLGPLApi());
Apis.add(new GitHubApacheApi());
Apis.add(new OpenVerseImagesApi());
Apis.add(new OpenVerseAudiosApi());
Apis.add(new CodeBergApi());
List<String> bindnames = new ArrayList<>();
for (Api api : Apis)
{
bindnames.add(api.getName());
}
return bindnames;
}
public List<element> out(Map<String, Integer> bindpages) throws Exception
{
List<element> Elements = new ArrayList<>();
for (int i = 0; i < Apis.size(); i++)
{
List<element> currentapi = Caller.CallApi(Apis.get(i), bindpages.get(Apis.get(i).getName()));
for (int j = 0; j < currentapi.size(); j++)
{
Elements.add(currentapi.get(j));
}
}
return Elements;
}
}
@@ -0,0 +1,50 @@
package org.sillyjirafe.uoapi;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.sillyjirafe.uoapi.binds.CodeBergApi;
import org.sillyjirafe.uoapi.binds.GitHubApacheApi;
import org.sillyjirafe.uoapi.binds.GitHubLGPLApi;
import org.sillyjirafe.uoapi.binds.GitHubMITApi;
import org.sillyjirafe.uoapi.binds.OpenVerseAudiosApi;
import org.sillyjirafe.uoapi.binds.OpenVerseImagesApi;
public class Out {
List<Api> Apis = new ArrayList<>();
public List<String> PreOut()
{
Apis.add(new GitHubMITApi());
Apis.add(new GitHubLGPLApi());
Apis.add(new GitHubApacheApi());
Apis.add(new OpenVerseImagesApi());
Apis.add(new OpenVerseAudiosApi());
List<String> bindnames = new ArrayList<>();
for (Api api : Apis)
{
bindnames.add(api.getName());
}
return bindnames;
}
public List<element> out(Map<String, Integer> bindpages) throws Exception
{
List<element> Elements = new ArrayList<>();
for (int i = 0; i < Apis.size(); i++)
{
List<element> currentapi = Caller.CallApi(Apis.get(i), bindpages.get(Apis.get(i).getName()));
for (int j = 0; j < currentapi.size(); j++)
{
Elements.add(currentapi.get(j));
}
}
return Elements;
}
}
@@ -0,0 +1,45 @@
package org.sillyjirafe.uoapi.binds;
import org.json.JSONArray;
import org.json.JSONObject;
import org.sillyjirafe.uoapi.Api;
import org.sillyjirafe.uoapi.element;
import java.util.ArrayList;
import java.util.List;
public class CodeBergApi implements Api
{
public String getName()
{
return "CadeBergApi";
}
public String getURL(int page) {
return "https://codeberg.org/api/v1/repos/search?page=" + page;
}
public List<element> Parse(String jsonRaw) {
List<element> resultats = new ArrayList<>();
try {
JSONObject json = new JSONObject(jsonRaw);
JSONArray items = json.getJSONArray("data");
for (int i = 0; i < items.length(); i++) {
JSONObject repo = items.getJSONObject(i);
String titre = repo.getString("full_name");
String url = repo.getString("html_url");
String licence = repo.getJSONObject("license").getString("spdx_id");
resultats.add(new element(titre, url, licence, "codeberg", "code"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}