This commit is contained in:
kotama committed 2026-09-10 13:54:59 +02:00
1 parent 8c690e216d
commit c6c7b99334
44 files changed
+2522 -1720

No files matched your search

@@ -0,0 +1,44 @@
package org.sillyjirafe.json;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class ApiKeys {
public static Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
try {
String jsonraw = Files.readString(filePath);
JSONObject json = new JSONObject(jsonraw);
Map<String, String> ApiKeys = new HashMap();
JSONArray items = json.getJSONArray("keys");
for (int i = 0; i < items.length(); i++) {
JSONObject key = items.getJSONObject(i);
String bind = key.getString("bind");
String password = key.getString("key");
ApiKeys.put(bind, password);
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -0,0 +1,44 @@
package org.sillyjirafe.uoapi.binds;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.sillyjirafe.uoapi.Api;
import org.sillyjirafe.uoapi.element;
public class PixabayImagesApi implements Api
{
public String getName()
{
return "PixabayImagesAPI";
}
public String getURL(int page, String apikey) {
return "https://pixabay.com/api/?per_page=200&page=" + page + "&key=" + apikey;
}
public List<element> Parse(String jsonRaw) {
List<element> resultats = new ArrayList<>();
try {
JSONObject json = new JSONObject(jsonRaw);
JSONArray items = json.getJSONArray("hits");
for (int i = 0; i < items.length(); i++) {
JSONObject repo = items.getJSONObject(i);
String titre = repo.getString("name");
String url = repo.getString("pageURL");
String licence = "CC0";
resultats.add(new element(titre, url, licence, "pixabay", "image"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -0,0 +1,45 @@
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.*;
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 PixabayImagesApi());
List<String> bindnames = new ArrayList<>();
for (Api api : Apis)
{
bindnames.add(api.getName());
}
return bindnames;
}
public List<element> out(Map<String, Integer> bindpages, Map<String, String> ApiKeys) 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()), ApiKeys.get(Apis.get(i).getName()));
for (int j = 0; j < currentapi.size(); j++)
{
Elements.add(currentapi.get(j));
}
}
return Elements;
}
}
@@ -0,0 +1,44 @@
package org.sillyjirafe.uoapi.binds;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.sillyjirafe.uoapi.Api;
import org.sillyjirafe.uoapi.element;
public class PixabayImagesApi implements Api
{
public String getName()
{
return "PixabayImagesAPI";
}
public String getURL(int page, String apikey) {
return "https://pixabay.com/api/?per_page=200&page=" + page + "&key=" + apikey;
}
public List<element> Parse(String jsonRaw) {
List<element> resultats = new ArrayList<>();
try {
JSONObject json = new JSONObject(jsonRaw);
JSONArray items = json.getJSONArray("");
for (int i = 0; i < items.length(); i++) {
JSONObject repo = items.getJSONObject(i);
String titre = repo.getString("name");
String url = repo.getString("pageURL");
String licence = "CC0";
resultats.add(new element(titre, url, licence, "pixabay", "image"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -0,0 +1,44 @@
package org.sillyjirafe.uoapi.binds;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.sillyjirafe.uoapi.Api;
import org.sillyjirafe.uoapi.element;
public class PixabayImagesApi implements Api
{
public String getName()
{
return "PixabayImagesAPI";
}
public String getURL(int page, String apikey) {
return "https://pixabay.com/api/?page=" + page + "key=" + apikey;
}
public List<element> Parse(String jsonRaw) {
List<element> resultats = new ArrayList<>();
try {
JSONObject json = new JSONObject(jsonRaw);
JSONArray items = json.getJSONArray("");
for (int i = 0; i < items.length(); i++) {
JSONObject repo = items.getJSONObject(i);
String titre = repo.getString("full_name");
String url = repo.getString("pageURL");
String licence = repo.getJSONObject("license").getString("spdx_id");
resultats.add(new element(titre, url, licence, "pixabay", "image"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -0,0 +1,44 @@
package org.sillyjirafe.uoapi.binds;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.sillyjirafe.uoapi.Api;
import org.sillyjirafe.uoapi.element;
public class PixabayImagesApi implements Api
{
public String getName()
{
return "PixabayImagesApi";
}
public String getURL(int page, String apikey) {
return "https://pixabay.com/api/?per_page=200&page=" + page + "&key=" + apikey;
}
public List<element> Parse(String jsonRaw) {
List<element> resultats = new ArrayList<>();
try {
JSONObject json = new JSONObject(jsonRaw);
JSONArray items = json.getJSONArray("hits");
for (int i = 0; i < items.length(); i++) {
JSONObject repo = items.getJSONObject(i);
String titre = repo.getString("name");
String url = repo.getString("pageURL");
String licence = "CC0";
resultats.add(new element(titre, url, licence, "pixabay", "image"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -0,0 +1,45 @@
package org.sillyjirafe.json;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class ApiKeys {
public static Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
Map<String, String> ApiKeys = new HashMap();
try {
String jsonraw = Files.readString(filePath);
JSONObject json = new JSONObject(jsonraw);
JSONArray items = json.getJSONArray("keys");
for (int i = 0; i < items.length(); i++) {
JSONObject key = items.getJSONObject(i);
String bind = key.getString("bind");
String password = key.getString("key");
ApiKeys.put(bind, password);
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -0,0 +1,44 @@
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.*;
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 PixabayImagesApi());
List<String> bindnames = new ArrayList<>();
for (Api api : Apis)
{
bindnames.add(api.getName());
}
return bindnames;
}
public List<element> out(Map<String, Integer> bindpages, Map<String, String> ApiKeys) 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()), ApiKeys.get(Apis.get(i).getName()));
for (int j = 0; j < currentapi.size(); j++)
{
Elements.add(currentapi.get(j));
}
}
return Elements;
}
}
@@ -0,0 +1,44 @@
package org.sillyjirafe.uoapi.binds;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.sillyjirafe.uoapi.Api;
import org.sillyjirafe.uoapi.element;
public class PixabayImagesApi implements Api
{
public String getName()
{
return "PixabayImagesAPI";
}
public String getURL(int page, String apikey) {
return "https://pixabay.com/api/?page=" + page + "key=" + apikey;
}
public List<element> Parse(String jsonRaw) {
List<element> resultats = new ArrayList<>();
try {
JSONObject json = new JSONObject(jsonRaw);
JSONArray items = json.getJSONArray("");
for (int i = 0; i < items.length(); i++) {
JSONObject repo = items.getJSONObject(i);
String titre = repo.getString("name");
String url = repo.getString("pageURL");
String licence = "CC0";
resultats.add(new element(titre, url, licence, "pixabay", "image"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -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.*;
import org.sillyjirafe.uoapi.binds.GitHubLGPLApi;
import org.sillyjirafe.uoapi.binds.GitHubMITApi;
import org.sillyjirafe.uoapi.binds.OpenVerseAudiosApi;
import org.sillyjirafe.uoapi.binds.OpenVerseImagesApi;
import org.sillyjirafe.uoapi.binds.PixabayImagesApi;
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 PixabayImagesApi());
List<String> bindnames = new ArrayList<>();
for (Api api : Apis)
{
bindnames.add(api.getName());
}
return bindnames;
}
public List<element> out(Map<String, Integer> bindpages, Map<String, String> ApiKeys) 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()), ApiKeys.get(Apis.get(i).getName()));
for (int j = 0; j < currentapi.size(); j++)
{
Elements.add(currentapi.get(j));
}
}
return Elements;
}
}
@@ -0,0 +1,44 @@
package org.sillyjirafe.uoapi.binds;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import org.sillyjirafe.uoapi.Api;
import org.sillyjirafe.uoapi.element;
public class PixabayImagesApi implements Api
{
public String getName()
{
return "PixabayImagesAPI";
}
public String getURL(int page, String apikey) {
return "https://pixabay.com/api/?page=" + page + "key=" + apikey;
}
public List<element> Parse(String jsonRaw) {
List<element> resultats = new ArrayList<>();
try {
JSONObject json = new JSONObject(jsonRaw);
JSONArray items = json.getJSONArray("");
for (int i = 0; i < items.length(); i++) {
JSONObject repo = items.getJSONObject(i);
String titre = repo.getString("name");
String url = repo.getString("pageURL");
String licence = repo.getJSONObject("license").getString("spdx_id");
resultats.add(new element(titre, url, licence, "pixabay", "image"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -0,0 +1,49 @@
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.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, Map<String, String> ApiKeys) 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()), ApiKeys.get(Apis.get(i).getName()));
for (int j = 0; j < currentapi.size(); j++)
{
Elements.add(currentapi.get(j));
}
}
return Elements;
}
}
@@ -0,0 +1,49 @@
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.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 PixabayImagesApi());
List<String> bindnames = new ArrayList<>();
for (Api api : Apis)
{
bindnames.add(api.getName());
}
return bindnames;
}
public List<element> out(Map<String, Integer> bindpages, Map<String, String> ApiKeys) 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()), ApiKeys.get(Apis.get(i).getName()));
for (int j = 0; j < currentapi.size(); j++)
{
Elements.add(currentapi.get(j));
}
}
return Elements;
}
}