0.0.1.6bis

This commit is contained in:
kotama committed 2026-10-04 17:04:38 +02:00
1 parent c6c7b99334
commit 97649d73eb
135 files changed
+2283 -6075

No files matched your search

@@ -1,44 +0,0 @@
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://api.github.com/search/repositories?q=license:apache-2.0&page=" + page;
}
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;
}
}
@@ -1,45 +0,0 @@
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;
}
}
@@ -1,94 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1
rnd TEXT NOT NULL DEFAULT a
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public String getRND(String bindName) throws SQLException {
String sql = "SELECT rnd FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getString("rnd");
} else {
return 1;
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,44 +0,0 @@
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;
}
}
@@ -1,44 +0,0 @@
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://api.github.com/search/repositories?q=license:apache-2.0&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, "pixabay", "code"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -1,49 +0,0 @@
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()));
for (int j = 0; j < currentapi.size(); j++)
{
Elements.add(currentapi.get(j));
}
}
return Elements;
}
}
@@ -1,44 +0,0 @@
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;
}
}
@@ -1,42 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
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("full_name");
String password = key.getString("key");
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,35 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
try {
String jsonraw = Files.readString(filePath);
JSONObject json = new JSONObject(jsonraw);
JSONArray items = json.getJSONArray("keys");
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,40 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
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 repo = items.getJSONObject(i);
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,5 +0,0 @@
package org.sillyjirafe.json;
public class ApiKeys {
}
@@ -1,94 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1,
rnd TEXT NOT NULL DEFAULT 'a'
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public String getRND(String bindName) throws SQLException {
String sql = "SELECT rnd FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getString("rnd");
} else {
return "a";
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,42 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
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");
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,49 +0,0 @@
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;
}
}
@@ -1,94 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1
rnd TEXT NOT NULL DEFAULT a
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public int getRND(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,28 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
Path filePath = Paths.get("ApiKeys.json");
try {
String jsonraw = Files.readString(filePath);
JSONObject json = new JSONObject(jsonraw);
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
}
}
@@ -1,105 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1,
rnd TEXT NOT NULL DEFAULT 'a'
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public String getRND(String bindName) throws SQLException {
String sql = "SELECT rnd FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getString("rnd");
} else {
return "a";
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public static String NextLetter(String actual) {
char lettre = actual.charAt(0);
if (lettre >= 'z') {
return "a";
}
char suivante = (char) (lettre + 1);
return String.valueOf(suivante);
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,14 +0,0 @@
package org.sillyjirafe.json;
import java.io.File;
import org.json.JSONObject;
public class ApiKeys {
public void read()
{
File file = new File("ApiKeys.json");
JSONObject json = new JSONObject();
}
}
@@ -1,11 +0,0 @@
package org.sillyjirafe.json;
import org.json.JSONObject;
public class ApiKeys {
public void read()
{
File myObj = new File("ApiKeys.json");
JSONObject json = new JSONObject();
}
}
@@ -1,94 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1
rnd TEXT NOT NULL DEFAULT a
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public String getRND(String bindName) throws SQLException {
String sql = "SELECT rnd FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getString("rnd");
} else {
return "a";
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,28 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
Path filePath = Paths.get("example.txt");
try {
List<String> lines = Files.readString(filePath);
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
JSONObject json = new JSONObject();
}
}
@@ -1,47 +0,0 @@
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 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;
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");
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,50 +0,0 @@
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 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;
}
}
@@ -1,45 +0,0 @@
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 GitHubLGPLApi implements Api
{
public String getName()
{
return "GitHubLGPLApi";
}
public String getURL(int page) {
return "https://api.github.com/search/repositories?q=license:lgpl-3.0&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, "github", "code"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -1,47 +0,0 @@
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 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");
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,29 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
Path filePath = Paths.get("ApiKeys.json");
JSONObject json = new JSONObject(jsonraw);
try {
String jsonraw = Files.readString(filePath);
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
JSONObject json = new JSONObject(jsonraw);
}
}
@@ -1,12 +0,0 @@
package org.sillyjirafe.json;
import java.io.File;
import org.json.JSONML;
public class ApiKeys {
public void read()
{
List<String> lines = Files.readAllLines(Paths.get("filename.txt"));
}
}
@@ -1,45 +0,0 @@
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 GitHubLGPLApi implements Api
{
public String getName()
{
return "GitHubLGPLApi";
}
public String getURL(int page) {
return "https://api.github.com/search/repositories?q=license:lgpl-3.0&page=" + page;
}
public List<element> Parse(String jsonRaw) {
List<element> resultats = new ArrayList<>();8
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, "github", "code"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -1,45 +0,0 @@
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;
}
}
@@ -1,45 +0,0 @@
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, "github", "code"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -1,5 +0,0 @@
package org.sillyjirafe.json;
public class ApiKeys {
}
@@ -1,5 +0,0 @@
package org.sillyjirafe.uoapi;
public class ApiKeys {
}
@@ -1,94 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1
rnd TEXT NOT NULL DEFAULT a
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public int getRND(String bindName) throws SQLException {
String sql = "SELECT rnd FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("rnd");
} else {
return 1;
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,9 +0,0 @@
package org.sillyjirafe.json;
public class ApiKeys {
public void read()
{
}
}
@@ -1,127 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1,
rnd TEXT NOT NULL DEFAULT 'a'
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public String getRND(String bindName) throws SQLException {
String sql = "SELECT rnd FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getString("rnd");
} else {
return "a";
}
}
}
public void updatePage(String bindName, int maxPage) throws SQLException {
int pageActuelle = getPage(bindName);
String rndActuel = getRND(bindName);
int nouvellePage;
String nouveauRnd;
if (pageActuelle >= maxPage) {
nouvellePage = 1;
nouveauRnd = NextLetter(rndActuel);
} else {
nouvellePage = pageActuelle + 1;
nouveauRnd = rndActuel;
}
String sql = """
INSERT INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)
ON CONFLICT(bind_name) DO UPDATE SET last_page = ?, rnd = ?
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.setInt(2, nouvellePage);
ps.setString(3, nouveauRnd);
ps.setInt(4, nouvellePage);
ps.setString(5, nouveauRnd);
ps.executeUpdate();
}
}
public static String NextLetter(String actual) {
char[] lettres = actual.toCharArray();
int i = lettres.length - 1;
while (i >= 0) {
if (lettres[i] < 'z') {
lettres[i]++;
return new String(lettres);
}
lettres[i] = 'a';
i--;
}
return "a" + new String(lettres);
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,23 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
Path filePath = Paths.get("ApiKeys.json");
String jsonraw = Files.readString(filePath);
}
JSONObject json = new JSONObject(jsonraw);
}
}
@@ -1,45 +0,0 @@
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 "GitHubMITApi";
}
public String getURL(int page) {
return "https://api.github.com/search/repositories?q=license:mit&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, "github", "code"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -1,31 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
Path filePath = Paths.get("example.txt");
try {
List<String> lines = Files.readAllLines(filePath);
for (String line : lines) {
System.out.println(line);
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
JSONObject json = new JSONObject();
}
}
@@ -1,94 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1
rnd TEXT NOT NULL DEFAULT a
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public int getRND(String bindName) throws SQLException {
String sql = "SELECT rnd FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,44 +0,0 @@
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;
}
}
@@ -1,31 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
try {
String jsonraw = Files.readString(filePath);
JSONObject json = new JSONObject(jsonraw);
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
}
}
@@ -1,44 +0,0 @@
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://api.github.com/search/repositories?q=license:apache-2.0&page=" + page;
}
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;
}
}
@@ -1,5 +0,0 @@
package org.sillyjirafe.uoapi;
public class ApiKeys {
}
@@ -1,49 +0,0 @@
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()));
for (int j = 0; j < currentapi.size(); j++)
{
Elements.add(currentapi.get(j));
}
}
return Elements;
}
}
@@ -1,94 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1,
rnd TEXT NOT NULL DEFAULT 'a'
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public String getRND(String bindName) throws SQLException {
String sql = "SELECT rnd FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getString("rnd");
} else {
return "a";
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,105 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1,
rnd TEXT NOT NULL DEFAULT 'a'
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public String getRND(String bindName) throws SQLException {
String sql = "SELECT rnd FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getString("rnd");
} else {
return "a";
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public static String lettreSuivante(String actuelle) {
char lettre = actuelle.charAt(0);
if (lettre >= 'z') {
return "a";
}
char suivante = (char) (lettre + 1);
return String.valueOf(suivante);
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,28 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
Path filePath = Paths.get("ApiKeys.json");
try {
String Jsonraw = Files.readString(filePath);
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
JSONObject json = new JSONObject(Jsonraw);
}
}
@@ -1,44 +0,0 @@
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;
}
}
@@ -1,51 +0,0 @@
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;
}
}
@@ -1,24 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
File file = new File("ApiKeys.json");
try (Scanner Reader = new Scanner(file)) {
Reader.all
}
JSONObject json = new JSONObject();
}
}
@@ -1,44 +0,0 @@
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://api.github.com/search/repositories?q=license:apache-2.0&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("pageURL");
String url = repo.getString("html_url");
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;
}
}
@@ -1,40 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
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 keys = items.getJSONObject(i);
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,44 +0,0 @@
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;
}
}
@@ -1,28 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
Path filePath = Paths.get("example.txt");
try {
List<String> lines = Files.readString(filePath)
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
JSONObject json = new JSONObject();
}
}
@@ -1,47 +0,0 @@
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 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");
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,94 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1
rnd TEXT NOT NULL DEFAULT a
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public int getRND(String bindName) throws SQLException {
String sql = "SELECT rnd FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getString("rnd");
} else {
return 1;
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,12 +0,0 @@
package org.sillyjirafe.json;
import java.io.File;
import org.json.JSONML;
public class ApiKeys {
public void read()
{
}
}
@@ -1,45 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Map<String, String> ApiKeys = new HashMap();
Path filePath = Paths.get("ApiKeys.json");
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");
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,45 +0,0 @@
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;
}
}
@@ -1,49 +0,0 @@
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()))
for (int j = 0; j < currentapi.size(); j++)
{
Elements.add(currentapi.get(j));
}
}
return Elements;
}
}
@@ -1,80 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1
rnd TEXT NOT NULL DEFAULT a
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,16 +0,0 @@
package org.sillyjirafe.json;
import java.io.File;
import org.json.JSONObject;
public class ApiKeys {
public void read()
{
File file = new File("ApiKeys.json");
try (Scanner myReader = new Scanner(myObj)) {
}
JSONObject json = new JSONObject();
}
}
@@ -1,44 +0,0 @@
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;
}
}
@@ -1,44 +0,0 @@
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;
}
}
@@ -1,33 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
try {
String jsonraw = Files.readString(filePath);
JSONObject json = new JSONObject(jsonraw);
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,50 +0,0 @@
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;
}
}
@@ -1,47 +0,0 @@
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;
}
}
@@ -1,40 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
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);
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,50 +0,0 @@
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;
}
}
@@ -1,44 +0,0 @@
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 OpenVerseAudiosApi implements Api
{
public String getName()
{
return "OpenVerseAudiosApi";
}
public String getURL(int page, String apikey) {
return "https://api.openverse.org/v1/audio/?format=json&page=" + page;
}
public List<element> Parse(String jsonRaw) {
List<element> resultats = new ArrayList<>();
try {
JSONObject json = new JSONObject(jsonRaw);
JSONArray items = json.getJSONArray("results");
for (int i = 0; i < items.length(); i++) {
JSONObject image = items.getJSONObject(i);
String titre = image.getString("title");
String url = image.getString("url");
String licence = image.getString("license");
resultats.add(new element(titre, url, licence, "openverse", "audio"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -1,37 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
try {
String jsonraw = Files.readString(filePath);
JSONObject json = new JSONObject(jsonraw);
JSONArray items = json.getJSONArray("keys");
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,44 +0,0 @@
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;
}
}
@@ -1,45 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Map<String, String> ApiKeys = new();
Path filePath = Paths.get("ApiKeys.json");
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");
}
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,25 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
Path filePath = Paths.get("ApiKeys.json");
File file = new File("ApiKeys.json");
try (Scanner Reader = new Scanner(file)) {
Reader.all
}
JSONObject json = new JSONObject();
}
}
@@ -1,45 +0,0 @@
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;
}
}
@@ -1,43 +0,0 @@
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 OpenVerseAudiosApi implements Api
{
public String getName()
{
return "OpenVerseAudiosApi";
}
public String getURL(int page, String apikey) {
return "https://api.openverse.org/v1/audio/?format=json&page=" + page;
}
public List<element> Parse(String jsonRaw) {
List<element> resultats = new ArrayList<>();
try {
JSONObject json = new JSONObject(jsonRaw);
JSONArray items = json.getJSONArray("results");
for (int i = 0; i < items.length(); i++) {
JSONObject image = items.getJSONObject(i);
String titre = image.getString("title");
String url = image.getString("url");
String licence = image.getString("license");
resultats.add(new element(titre, url, licence, "openverse", "audio"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -1,94 +0,0 @@
package org.sillyjirafe.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Crawl_StateDB
{
String URL = new String();
String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)";
Connection connection;
public Crawl_StateDB(String BDstr) throws SQLException
{
URL = BDstr;
connection = DriverManager.getConnection(URL);
}
public void LinkToDB() throws SQLException
{
try (Statement stmt = connection.createStatement())
{
stmt.execute("""
CREATE TABLE IF NOT EXISTS crawlstates (
bind_name TEXT PRIMARY KEY,
last_page INTEGER NOT NULL DEFAULT 1,
rnd TEXT NOT NULL DEFAULT a
)
""");
}
}
public void AddEllement(String bind, int lastpage) throws SQLException
{
try (PreparedStatement ps = connection.prepareStatement(insertSql))
{
ps.setString(1, bind);
ps.setInt(2, lastpage);
ps.executeUpdate();
System.out.printf("%s is now page %d \n", bind, lastpage);
}
}
public int getPage(String bindName) throws SQLException {
String sql = "SELECT last_page FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt("last_page");
} else {
return 1;
}
}
}
public String getRND(String bindName) throws SQLException {
String sql = "SELECT rnd FROM crawlstates WHERE bind_name = ?";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getString("rnd");
} else {
return "a";
}
}
}
public void updatePage(String bindName) throws SQLException {
String sql = """
INSERT INTO crawlstates (bind_name, last_page) VALUES (?, 2)
ON CONFLICT(bind_name) DO UPDATE SET last_page = last_page + 1
""";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, bindName);
ps.executeUpdate();
}
}
public void Close() throws SQLException
{
if (connection != null)
{
connection.close();
}
}
}
@@ -1,28 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
Path filePath = Paths.get("ApiKeys.json");
try {
String jsonraw = Files.readString(filePath);
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
JSONObject json = new JSONObject(jsonraw);
}
}
@@ -1,22 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
Path filePath = Paths.get("ApiKeys.json");
String jsonraw = Files.readString(filePath);
JSONObject json = new JSONObject(jsonraw);
}
}
@@ -1,45 +0,0 @@
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 GitHubMITApi implements Api
{
public String getName()
{
return "GitHubMITApi";
}
public String getURL(int page, String apikey) {
return "https://api.github.com/search/repositories?q=license:mit&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, "github", "code"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -1,28 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public void read() throws FileNotFoundException
{
Path filePath = Paths.get("ApiKeys.json");
try {
String jsonraw = Files.readString(filePath);
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
JSONObject json = new JSONObject(jsonraw);
}
}
@@ -1,44 +0,0 @@
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 "GitHubApacheApi";
}
public String getURL(int page, String apikey) {
return "https://api.github.com/search/repositories?q=license:apache-2.0&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, "github", "code"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -1,44 +0,0 @@
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;
}
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;
}
}
@@ -1,49 +0,0 @@
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;
}
}
@@ -1,44 +0,0 @@
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://api.github.com/search/repositories?q=license:apache-2.0&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("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;
}
}
@@ -1,49 +0,0 @@
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;
}
}
@@ -1,49 +0,0 @@
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;
}
}
@@ -1,28 +0,0 @@
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.List;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read() throws FileNotFoundException
{
Path filePath = Paths.get("ApiKeys.json");
try {
String jsonraw = Files.readString(filePath);
JSONObject json = new JSONObject(jsonraw);
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
}
}
@@ -1,33 +0,0 @@
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.List;
import java.util.Map;
import org.json.JSONObject;
public class ApiKeys {
public Map<String, String> read()
{
Path filePath = Paths.get("ApiKeys.json");
try {
String jsonraw = Files.readString(filePath);
JSONObject json = new JSONObject(jsonraw);
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
} catch (SecurityException e) {
System.err.println("Access denied: " + e.getMessage());
}
return null;
}
}
@@ -1,44 +0,0 @@
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://api.github.com/search/repositories?q=license:apache-2.0&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, "github", "code"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -1,44 +0,0 @@
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://api.github.com/search/repositories?q=license:apache-2.0&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, "pixabay", "image"));
}
} catch (org.json.JSONException e) {
System.out.println("error but continue : " + e.getMessage());
}
return resultats;
}
}
@@ -1,49 +0,0 @@
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;
}
}
Loaded 100 of 135 files, more files were not shown because too many files have changed in this diff. Show more