diff --git a/.metadata/.lock_info b/.metadata/.lock_info index 644b25b..36d1d83 100644 --- a/.metadata/.lock_info +++ b/.metadata/.lock_info @@ -1,4 +1,4 @@ -#Sat Aug 29 13:08:22 CEST 2026 -host=fedora.home +#Sun Sep 06 13:03:29 CEST 2026 +host=fedora process-id=3 user=Kotama_Chio diff --git a/.metadata/.log b/.metadata/.log index 4308e9a..e9460d1 100644 --- a/.metadata/.log +++ b/.metadata/.log @@ -873,3 +873,42 @@ java.lang.Exception: The project description file (.project) for 'SillyBlahaj.or !ENTRY org.eclipse.jdt.core 4 969 2026-08-29 13:09:22.631 !MESSAGE sillyblahaj.org.api does not exist +!SESSION 2026-08-31 20:39:00.304 ----------------------------------------------- +eclipse.buildId=4.40.0.20260604-0652 +java.version=21.0.11 +java.vendor=Eclipse Adoptium +BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY ch.qos.logback.classic 1 0 2026-08-31 20:39:05.040 +!MESSAGE Activated before the state location was initialized. Retry after the state location is initialized. + +!ENTRY ch.qos.logback.classic 1 0 2026-08-31 20:39:08.198 +!MESSAGE Logback config file: /home/Kotama_Chio/Musique/SillyBlahaj.org/Java/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.7.101.20251017-1242.xml +!SESSION 2026-09-05 11:06:23.210 ----------------------------------------------- +eclipse.buildId=4.40.0.20260604-0652 +java.version=21.0.11 +java.vendor=Eclipse Adoptium +BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY ch.qos.logback.classic 1 0 2026-09-05 11:06:28.586 +!MESSAGE Activated before the state location was initialized. Retry after the state location is initialized. + +!ENTRY ch.qos.logback.classic 1 0 2026-09-05 11:06:34.203 +!MESSAGE Logback config file: /home/Kotama_Chio/Musique/SillyBlahaj.org/Java/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.7.101.20251017-1242.xml +!SESSION 2026-09-06 13:03:22.499 ----------------------------------------------- +eclipse.buildId=4.40.0.20260604-0652 +java.version=21.0.11 +java.vendor=Eclipse Adoptium +BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY ch.qos.logback.classic 1 0 2026-09-06 13:03:27.448 +!MESSAGE Activated before the state location was initialized. Retry after the state location is initialized. + +!ENTRY ch.qos.logback.classic 1 0 2026-09-06 13:03:30.006 +!MESSAGE Logback config file: /home/Kotama_Chio/Musique/SillyBlahaj.org/Java/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.7.101.20251017-1242.xml diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/19/c043650f18a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/19/c043650f18a90011182fc3eab58d65be new file mode 100644 index 0000000..68cc1c7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/19/c043650f18a90011182fc3eab58d65be @@ -0,0 +1,94 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/31/b0635be19aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/31/b0635be19aa30011197aae2d8f81f7b0 deleted file mode 100644 index 31dbba4..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/31/b0635be19aa30011197aae2d8f81f7b0 +++ /dev/null @@ -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.sillyblahaj.uoapi.Api; -import org.sillyblahaj.uoapi.element; - -public class OpenVerseImagesApi implements Api -{ - public String getName() - { - return "OpenVerseImagesApi"; - } - - public String getURL(int page) { - return "https://api.openverse.org/v1/images/?format=json&page=" + page; - } - - public List Parse(String jsonRaw) { - List 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", "image")); - } - } catch (org.json.JSONException e) { - System.out.println("error but continue : " + e.getMessage()); - } - return resultats; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/37/704db65f9aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/37/704db65f9aa30011197aae2d8f81f7b0 deleted file mode 100644 index db304d1..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/37/704db65f9aa30011197aae2d8f81f7b0 +++ /dev/null @@ -1,25 +0,0 @@ -package org.sillyjirafe.api; - -import java.util.List; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.sillyblahaj.uoapi.element; - -public class Json { - public static String JSONConvert(List elements) { - JSONArray tableau = new JSONArray(); - - for (element e : elements) { - JSONObject obj = new JSONObject(); - obj.put("title", e.title()); - obj.put("url", e.url()); - obj.put("licence", e.licence()); - obj.put("source", e.source()); - obj.put("type", e.type()); - tableau.put(obj); - } - - return tableau.toString(); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3f/30b8798d23a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/3f/30b8798d23a90011182fc3eab58d65be new file mode 100644 index 0000000..ef75b26 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3f/30b8798d23a90011182fc3eab58d65be @@ -0,0 +1,94 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/42/c00794f417a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/42/c00794f417a90011182fc3eab58d65be new file mode 100644 index 0000000..e904e80 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/42/c00794f417a90011182fc3eab58d65be @@ -0,0 +1,94 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/44/d0420dfd18a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/44/d0420dfd18a90011182fc3eab58d65be new file mode 100644 index 0000000..684879c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/44/d0420dfd18a90011182fc3eab58d65be @@ -0,0 +1,105 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4e/f038116618a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/4e/f038116618a90011182fc3eab58d65be new file mode 100644 index 0000000..1ebcdd5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4e/f038116618a90011182fc3eab58d65be @@ -0,0 +1,94 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/42/d0de85f89aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/53/60540e2c15a90011182fc3eab58d65be similarity index 78% rename from .metadata/.plugins/org.eclipse.core.resources/.history/42/d0de85f89aa30011197aae2d8f81f7b0 rename to .metadata/.plugins/org.eclipse.core.resources/.history/53/60540e2c15a90011182fc3eab58d65be index b9812f0..3391050 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/42/d0de85f89aa30011197aae2d8f81f7b0 +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/53/60540e2c15a90011182fc3eab58d65be @@ -5,11 +5,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.sillyblahaj.uoapi.binds.GitHubApacheApi; -import org.sillyblahaj.uoapi.binds.GitHubLGPLApi; -import org.sillyblahaj.uoapi.binds.GitHubMITApi; -import org.sillyblahaj.uoapi.binds.OpenVerseAudiosApi; -import org.sillyblahaj.uoapi.binds.OpenVerseImagesApi; +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 Apis = new ArrayList<>(); @@ -21,6 +21,7 @@ public class Out { Apis.add(new GitHubApacheApi()); Apis.add(new OpenVerseImagesApi()); Apis.add(new OpenVerseAudiosApi()); + Apis.add(new CodeBergApi())); List bindnames = new ArrayList<>(); diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5a/c0871b5717a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/5a/c0871b5717a90011182fc3eab58d65be new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5e/1088a1499aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/5e/1088a1499aa30011197aae2d8f81f7b0 deleted file mode 100644 index e1f989e..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5e/1088a1499aa30011197aae2d8f81f7b0 +++ /dev/null @@ -1,58 +0,0 @@ -package org.sillyjirafe.api; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.sillyblahaj.uoapi.element; - -import com.sun.net.httpserver.HttpServer; - -public class Start { - public static void API(Connection conn) throws IOException { - HttpServer server = HttpServer.create(new InetSocketAddress(8081), 0); - - server.createContext("/search", exchange -> { - String query = exchange.getRequestURI().getQuery(); - Map settings = parseQuery(query); - - try { - List results = Search.search(conn, settings); - String json = Json.JSONConvert(results); - - exchange.getResponseHeaders().set("Content-Type", "application/json"); - exchange.sendResponseHeaders(200, json.getBytes().length); - exchange.getResponseBody().write(json.getBytes()); - exchange.getResponseBody().close(); - } catch (Exception e) { - e.printStackTrace(); - exchange.sendResponseHeaders(500, 0); - exchange.getResponseBody().close(); - } - }); - - server.start(); - System.out.println("Search API run on 8081 port"); - } - - public static Map parseQuery(String query) { - Map params = new HashMap<>(); - - if (query == null) return params; - - String[] paires = query.split("&"); - - for (String paire : paires) { - String[] cle_valeur = paire.split("=", 2); - if (cle_valeur.length == 2) { - params.put(cle_valeur[0], cle_valeur[1]); - } - } - - return params; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1b/c050a8ba9aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/66/e0da330f15a90011182fc3eab58d65be similarity index 82% rename from .metadata/.plugins/org.eclipse.core.resources/.history/1b/c050a8ba9aa30011197aae2d8f81f7b0 rename to .metadata/.plugins/org.eclipse.core.resources/.history/66/e0da330f15a90011182fc3eab58d65be index 0910b06..598cd71 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1b/c050a8ba9aa30011197aae2d8f81f7b0 +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/66/e0da330f15a90011182fc3eab58d65be @@ -1,28 +1,28 @@ -package org.sillyjrafe.uoapi.binds; - -import java.util.ArrayList; -import java.util.List; +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 GitHubLGPLApi implements Api +public class CodeBergApi implements Api { public String getName() { - return "GitHubLGPLApi"; + return "CadeBergApi"; } public String getURL(int page) { - return "https://api.github.com/search/repositories?q=license:lgpl-3.0&page=" + page; + return "https://codeberg.org/api/v1/repos/search?page=" + page; } public List Parse(String jsonRaw) { List resultats = new ArrayList<>(); + try { JSONObject json = new JSONObject(jsonRaw); JSONArray items = json.getJSONArray("items"); diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/70/f01b798d23a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/70/f01b798d23a90011182fc3eab58d65be new file mode 100644 index 0000000..0a371e6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/70/f01b798d23a90011182fc3eab58d65be @@ -0,0 +1,5 @@ +package org.sillyjirafe.uoapi; + +public class ApiKeys { + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/73/f0ba830318a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/73/f0ba830318a90011182fc3eab58d65be new file mode 100644 index 0000000..6f31353 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/73/f0ba830318a90011182fc3eab58d65be @@ -0,0 +1,94 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/76/b09ff04519a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/76/b09ff04519a90011182fc3eab58d65be new file mode 100644 index 0000000..6f35584 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/76/b09ff04519a90011182fc3eab58d65be @@ -0,0 +1,127 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7e/a0ca6ecc9aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/7b/306207b014a90011182fc3eab58d65be similarity index 89% rename from .metadata/.plugins/org.eclipse.core.resources/.history/7e/a0ca6ecc9aa30011197aae2d8f81f7b0 rename to .metadata/.plugins/org.eclipse.core.resources/.history/7b/306207b014a90011182fc3eab58d65be index edc9ba8..6d96581 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7e/a0ca6ecc9aa30011197aae2d8f81f7b0 +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/7b/306207b014a90011182fc3eab58d65be @@ -2,12 +2,12 @@ package org.sillyjirafe.uoapi.binds; import org.json.JSONArray; import org.json.JSONObject; -import org.sillyblahaj.uoapi.Api; -import org.sillyblahaj.uoapi.element; +import org.sillyjirafe.uoapi.Api; +import org.sillyjirafe.uoapi.element; import java.util.ArrayList; import java.util.List; -public class GitHubMITApi implements Api +public class CodeBergApi implements Api { public String getName() diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7d/c075c3f717a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/7d/c075c3f717a90011182fc3eab58d65be new file mode 100644 index 0000000..5646a11 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/7d/c075c3f717a90011182fc3eab58d65be @@ -0,0 +1,94 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/86/60397b9018a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/86/60397b9018a90011182fc3eab58d65be new file mode 100644 index 0000000..ef75b26 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/86/60397b9018a90011182fc3eab58d65be @@ -0,0 +1,94 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/86/80864e9b18a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/86/80864e9b18a90011182fc3eab58d65be new file mode 100644 index 0000000..0da0eb3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/86/80864e9b18a90011182fc3eab58d65be @@ -0,0 +1,105 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/89/e0554c3d9aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/89/e0554c3d9aa30011197aae2d8f81f7b0 deleted file mode 100644 index d893ee4..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/89/e0554c3d9aa30011197aae2d8f81f7b0 +++ /dev/null @@ -1,58 +0,0 @@ -package org.sillyblahaj.api; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.sillyblahaj.uoapi.element; - -import com.sun.net.httpserver.HttpServer; - -public class Start { - public static void API(Connection conn) throws IOException { - HttpServer server = HttpServer.create(new InetSocketAddress(8081), 0); - - server.createContext("/search", exchange -> { - String query = exchange.getRequestURI().getQuery(); - Map settings = parseQuery(query); - - try { - List results = Search.search(conn, settings); - String json = Json.JSONConvert(results); - - exchange.getResponseHeaders().set("Content-Type", "application/json"); - exchange.sendResponseHeaders(200, json.getBytes().length); - exchange.getResponseBody().write(json.getBytes()); - exchange.getResponseBody().close(); - } catch (Exception e) { - e.printStackTrace(); - exchange.sendResponseHeaders(500, 0); - exchange.getResponseBody().close(); - } - }); - - server.start(); - System.out.println("Search API run on 8081 port"); - } - - public static Map parseQuery(String query) { - Map params = new HashMap<>(); - - if (query == null) return params; - - String[] paires = query.split("&"); - - for (String paire : paires) { - String[] cle_valeur = paire.split("=", 2); - if (cle_valeur.length == 2) { - params.put(cle_valeur[0], cle_valeur[1]); - } - } - - return params; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8a/b01d73d89aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/8a/b01d73d89aa30011197aae2d8f81f7b0 deleted file mode 100644 index 5eaa9d9..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8a/b01d73d89aa30011197aae2d8f81f7b0 +++ /dev/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.sillyblahaj.uoapi.element; - -public class OpenVerseAudiosApi implements Api -{ - public String getName() - { - return "OpenVerseAudiosApi"; - } - - public String getURL(int page) { - return "https://api.openverse.org/v1/audio/?format=json&page=" + page; - } - - public List Parse(String jsonRaw) { - List 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; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ae/c06b1d0c18a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/ae/c06b1d0c18a90011182fc3eab58d65be new file mode 100644 index 0000000..61d42ee --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ae/c06b1d0c18a90011182fc3eab58d65be @@ -0,0 +1,94 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/af/e042b7c19aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/af/e042b7c19aa30011197aae2d8f81f7b0 deleted file mode 100644 index cfef228..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/af/e042b7c19aa30011197aae2d8f81f7b0 +++ /dev/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.sillyblahaj.uoapi.Api; -import org.sillyblahaj.uoapi.element; - -public class GitHubApacheApi implements Api -{ - public String getName() - { - return "GitHubApacheApi"; - } - - public String getURL(int page) { - return "https://api.github.com/search/repositories?q=license:apache-2.0&page=" + page; - } - - public List Parse(String jsonRaw) { - List 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; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b2/5006d8ef17a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/b2/5006d8ef17a90011182fc3eab58d65be new file mode 100644 index 0000000..92412af --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b2/5006d8ef17a90011182fc3eab58d65be @@ -0,0 +1,80 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/504c0be59aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/504c0be59aa30011197aae2d8f81f7b0 deleted file mode 100644 index b3a8f92..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/504c0be59aa30011197aae2d8f81f7b0 +++ /dev/null @@ -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.sillyblahaj.uoapi.element; - -public class OpenVerseImagesApi implements Api -{ - public String getName() - { - return "OpenVerseImagesApi"; - } - - public String getURL(int page) { - return "https://api.openverse.org/v1/images/?format=json&page=" + page; - } - - public List Parse(String jsonRaw) { - List 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", "image")); - } - } catch (org.json.JSONException e) { - System.out.println("error but continue : " + e.getMessage()); - } - return resultats; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bd/b0507b399aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/bd/b0507b399aa30011197aae2d8f81f7b0 deleted file mode 100644 index 2f66f6f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bd/b0507b399aa30011197aae2d8f81f7b0 +++ /dev/null @@ -1,44 +0,0 @@ -package org.sillyblahaj.api; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.sillyblahaj.uoapi.element; - -public class Search { - public static List search(Connection conn, Map settings) throws SQLException { - List results = new ArrayList<>(); - String sql = """ - SELECT * FROM creations - WHERE (? = '' OR title LIKE ?) - AND (? = '' OR licence = ?) - AND (? = '' OR type = ?) - """; - - try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setString(1, settings.getOrDefault("q", "")); - ps.setString(2, "%" + settings.getOrDefault("q", "") + "%"); - ps.setString(3, settings.getOrDefault("licence", "")); - ps.setString(4, settings.getOrDefault("licence", "")); - ps.setString(5, settings.getOrDefault("type", "")); - ps.setString(6, settings.getOrDefault("type", "")); - ResultSet rs = ps.executeQuery(); - - while (rs.next()) { - results.add(new element( - rs.getString("title"), - rs.getString("url"), - rs.getString("licence"), - rs.getString("source"), - rs.getString("type") - )); - } - } - return results; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ca/60fd6f929aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/ca/60fd6f929aa30011197aae2d8f81f7b0 deleted file mode 100644 index 3fc2f91..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ca/60fd6f929aa30011197aae2d8f81f7b0 +++ /dev/null @@ -1,42 +0,0 @@ -package org.sillyjirafe.linker; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.sillyblahaj.db.Crawl_StateDB; -import org.sillyblahaj.db.ElementsDB; -import org.sillyblahaj.uoapi.*; - -public class Main { - public static void main(String[] args) throws Exception - { - Out Out = new Out(); - ElementsDB elementDB = new ElementsDB("jdbc:sqlite:elements.db"); - Crawl_StateDB crawlstateDB = new Crawl_StateDB("jdbc:sqlite:crawlstates.db"); - elementDB.LinkToDB(); - crawlstateDB.LinkToDB(); - - List bindNames = Out.PreOut(); - - Map pages = new HashMap<>(); - for (String nom : bindNames) { - pages.put(nom, crawlstateDB.getPage(nom)); - } - - List elements = Out.out(pages); - - for (int i = 0; i < elements.size(); i++) - { - element el = elements.get(i); - elementDB.AddEllement(el.title(), el.url(), el.licence(), el.source(), el.type()); - } - - for (String name : bindNames) { - crawlstateDB.updatePage(name); - } - - elementDB.Close(); - crawlstateDB.Close(); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ce/602754579aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/ce/602754579aa30011197aae2d8f81f7b0 deleted file mode 100644 index 3e03d2b..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ce/602754579aa30011197aae2d8f81f7b0 +++ /dev/null @@ -1,44 +0,0 @@ -package org.sillyjirafe.api; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.sillyblahaj.uoapi.element; - -public class Search { - public static List search(Connection conn, Map settings) throws SQLException { - List results = new ArrayList<>(); - String sql = """ - SELECT * FROM creations - WHERE (? = '' OR title LIKE ?) - AND (? = '' OR licence = ?) - AND (? = '' OR type = ?) - """; - - try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setString(1, settings.getOrDefault("q", "")); - ps.setString(2, "%" + settings.getOrDefault("q", "") + "%"); - ps.setString(3, settings.getOrDefault("licence", "")); - ps.setString(4, settings.getOrDefault("licence", "")); - ps.setString(5, settings.getOrDefault("type", "")); - ps.setString(6, settings.getOrDefault("type", "")); - ResultSet rs = ps.executeQuery(); - - while (rs.next()) { - results.add(new element( - rs.getString("title"), - rs.getString("url"), - rs.getString("licence"), - rs.getString("source"), - rs.getString("type") - )); - } - } - return results; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/da/401c957218a90011182fc3eab58d65be b/.metadata/.plugins/org.eclipse.core.resources/.history/da/401c957218a90011182fc3eab58d65be new file mode 100644 index 0000000..cf7c022 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/da/401c957218a90011182fc3eab58d65be @@ -0,0 +1,94 @@ +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(); + } + } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/dd/907434959aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/dd/907434959aa30011197aae2d8f81f7b0 deleted file mode 100644 index b16de8b..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/dd/907434959aa30011197aae2d8f81f7b0 +++ /dev/null @@ -1,42 +0,0 @@ -package org.sillyjirafe.linker; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.sillyjirafe.db.Crawl_StateDB; -import org.sillyjirafe.db.ElementsDB; -import org.sillyblahaj.uoapi.*; - -public class Main { - public static void main(String[] args) throws Exception - { - Out Out = new Out(); - ElementsDB elementDB = new ElementsDB("jdbc:sqlite:elements.db"); - Crawl_StateDB crawlstateDB = new Crawl_StateDB("jdbc:sqlite:crawlstates.db"); - elementDB.LinkToDB(); - crawlstateDB.LinkToDB(); - - List bindNames = Out.PreOut(); - - Map pages = new HashMap<>(); - for (String nom : bindNames) { - pages.put(nom, crawlstateDB.getPage(nom)); - } - - List elements = Out.out(pages); - - for (int i = 0; i < elements.size(); i++) - { - element el = elements.get(i); - elementDB.AddEllement(el.title(), el.url(), el.licence(), el.source(), el.type()); - } - - for (String name : bindNames) { - crawlstateDB.updatePage(name); - } - - elementDB.Close(); - crawlstateDB.Close(); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e3/00e699d59aa30011197aae2d8f81f7b0 b/.metadata/.plugins/org.eclipse.core.resources/.history/e3/00e699d59aa30011197aae2d8f81f7b0 deleted file mode 100644 index 79b1bd3..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e3/00e699d59aa30011197aae2d8f81f7b0 +++ /dev/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.sillyblahaj.uoapi.Api; -import org.sillyblahaj.uoapi.element; - -public class OpenVerseAudiosApi implements Api -{ - public String getName() - { - return "OpenVerseAudiosApi"; - } - - public String getURL(int page) { - return "https://api.openverse.org/v1/audio/?format=json&page=" + page; - } - - public List Parse(String jsonRaw) { - List 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; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/40/d6/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/40/d6/history.index index 779553e..10028a6 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/40/d6/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/40/d6/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/40/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/40/history.index index fc84f98..5ff20b9 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/40/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/40/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/7e/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/7e/history.index new file mode 100644 index 0000000..6dd7d6e Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/7e/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/d9/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/d9/history.index deleted file mode 100644 index 7a6073b..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.indexes/e4/e4/90/d9/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.markers b/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.markers index 6b14ecb..edb95e0 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.markers and b/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/.markers differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/org.eclipse.jdt.core/state.dat index e4af2b0..aa50977 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/org.eclipse.jdt.core/state.dat and b/.metadata/.plugins/org.eclipse.core.resources/.projects/SillyJirafe.org/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/sillyjirafe.org.api/.indexes/e4/e4/90/1a/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/sillyjirafe.org.api/.indexes/e4/e4/90/1a/history.index deleted file mode 100644 index 4b120c9..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/sillyjirafe.org.api/.indexes/e4/e4/90/1a/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/sillyjirafe.org.api/.markers b/.metadata/.plugins/org.eclipse.core.resources/.projects/sillyjirafe.org.api/.markers index d54e513..1bf82bf 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/sillyjirafe.org.api/.markers and b/.metadata/.plugins/org.eclipse.core.resources/.projects/sillyjirafe.org.api/.markers differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/sillyjirafe.org.api/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/sillyjirafe.org.api/org.eclipse.jdt.core/state.dat index a2dc46b..ae28f6b 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/sillyjirafe.org.api/org.eclipse.jdt.core/state.dat and b/.metadata/.plugins/org.eclipse.core.resources/.projects/sillyjirafe.org.api/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/16.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/16.tree deleted file mode 100644 index 46d91b0..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.root/16.tree and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/19.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/19.tree new file mode 100644 index 0000000..f79db6b Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/19.tree differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources index 7c9efcc..1a1e44d 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources and b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs index f8e0a1e..ed680bb 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs @@ -1,6 +1,7 @@ //org.eclipse.ui.commands/state/org.eclipse.ui.navigator.resources.nested.changeProjectPresentation/org.eclipse.ui.commands.radioState=false PLUGINS_NOT_ACTIVATED_ON_STARTUP=;org.eclipse.m2e.discovery; eclipse.preferences.version=1 +org.eclipse.jdt.ui.ColoredLabels.match_highlight=206,92,0 org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_END=41,41,41 org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START=43,44,45 org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_TEXT_COLOR=255,255,255 diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi index f275f37..f9ea65d 100644 --- a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -1,6 +1,6 @@ - + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration @@ -80,10 +80,11 @@ persp.editorOnboardingCommand:Show Key Assist$$$Shift+Ctrl+L persp.editorOnboardingCommand:New$$$Ctrl+N persp.editorOnboardingCommand:Open Type$$$Shift+Ctrl+T - + org.eclipse.e4.primaryNavigationStack + active View categoryTag:Java @@ -218,10 +219,9 @@ categoryTag:Help - + EditorStack org.eclipse.e4.primaryDataStack - active Editor @@ -253,12 +253,10 @@ org.eclipse.jdt.ui.CompilationUnitEditor - + Editor removeOnHide org.eclipse.jdt.ui.CompilationUnitEditor - active - activeOnClose @@ -267,7 +265,7 @@ org.eclipse.jdt.ui.CompilationUnitEditor - + Editor removeOnHide org.eclipse.jdt.ui.CompilationUnitEditor @@ -291,7 +289,7 @@ org.eclipse.jdt.ui.CompilationUnitEditor - + Editor removeOnHide org.eclipse.jdt.ui.CompilationUnitEditor @@ -309,7 +307,7 @@ org.eclipse.jdt.ui.CompilationUnitEditor - + Editor removeOnHide org.eclipse.jdt.ui.CompilationUnitEditor @@ -326,6 +324,18 @@ removeOnHide org.eclipse.jdt.ui.CompilationUnitEditor + + + Editor + removeOnHide + org.eclipse.jdt.ui.CompilationUnitEditor + + + + Editor + removeOnHide + org.eclipse.jdt.ui.CompilationUnitEditor + @@ -334,6 +344,8 @@ View categoryTag:Java + active + activeOnClose ViewMenu menuContribution:menu @@ -355,7 +367,7 @@ - + View categoryTag:General @@ -479,7 +491,7 @@ Draggable - + toolbarSeparator @@ -487,8 +499,8 @@ Draggable - - + + toolbarSeparator @@ -512,7 +524,7 @@ Draggable - + toolbarSeparator @@ -2542,7 +2554,7 @@ - + diff --git a/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index b/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index index 69aee0b..6747fd5 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index and b/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/206920101.index b/.metadata/.plugins/org.eclipse.jdt.core/206920101.index index f771e25..67b4481 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/206920101.index and b/.metadata/.plugins/org.eclipse.jdt.core/206920101.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt b/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt index 894546b..8050890 100644 --- a/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt +++ b/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt @@ -1,4 +1,7 @@ INDEX VERSION 1.134+/home/Kotama_Chio/Musique/SillyBlahaj.org/Java/.metadata/.plugins/org.eclipse.jdt.core 263131634.index +1568060524.index +1241313270.index 206920101.index +4139034169.index 1865797976.index diff --git a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat index dc7501e..03c47c5 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat and b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/0.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/0.png new file mode 100644 index 0000000..f8696d9 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/0.png differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/1.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/1.png new file mode 100644 index 0000000..aba8b33 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/1.png differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/2.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/2.png new file mode 100644 index 0000000..e671ee2 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/2.png differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/3.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/3.png new file mode 100644 index 0000000..90f564a Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/3.png differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/4.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/4.png new file mode 100644 index 0000000..41f82f2 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/4.png differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/5.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/5.png new file mode 100644 index 0000000..f3316de Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/5.png differ diff --git a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/36/refactorings.history b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/36/refactorings.history new file mode 100644 index 0000000..cca6ef6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/36/refactorings.history @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/36/refactorings.index b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/36/refactorings.index new file mode 100644 index 0000000..574adc8 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/36/refactorings.index @@ -0,0 +1 @@ +1788604141896 Copy compilation unit diff --git a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/37/refactorings.history b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/37/refactorings.history new file mode 100644 index 0000000..4e9b3b2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/37/refactorings.history @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/37/refactorings.index b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/37/refactorings.index new file mode 100644 index 0000000..b78dc4a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/SillyJirafe.org/2026/9/37/refactorings.index @@ -0,0 +1 @@ +1788693077363 Delete elements diff --git a/.metadata/.plugins/org.eclipse.m2e.logback/0.log b/.metadata/.plugins/org.eclipse.m2e.logback/0.log index 6cc56a3..9e02be7 100644 --- a/.metadata/.plugins/org.eclipse.m2e.logback/0.log +++ b/.metadata/.plugins/org.eclipse.m2e.logback/0.log @@ -14,3 +14,6 @@ 2026-08-28 21:24:21,650 [Worker-5: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. 2026-08-29 13:04:25,454 [Worker-9: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. 2026-08-29 13:08:26,670 [Worker-6: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. +2026-08-31 20:39:13,052 [Worker-8: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. +2026-09-05 11:06:39,935 [Worker-5: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. +2026-09-06 13:03:34,770 [Worker-2: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. diff --git a/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml index 7772e40..e61ba78 100644 --- a/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml +++ b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -34,7 +34,7 @@
- +
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml index 7d9debc..f1b3ad6 100644 --- a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml +++ b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -9,7 +9,7 @@
- + @@ -24,4 +24,18 @@
+
+ + + + + +
+ + + + + +
+
diff --git a/.metadata/version.ini b/.metadata/version.ini index b9eddbc..869ab8d 100644 --- a/.metadata/version.ini +++ b/.metadata/version.ini @@ -1,3 +1,3 @@ -#Sat Aug 29 13:08:22 CEST 2026 +#Sun Sep 06 13:03:29 CEST 2026 org.eclipse.core.runtime=2 org.eclipse.platform=4.40.0.v20260601-0713 diff --git a/SillyJirafe.org/bin/org/sillyjirafe/db/Crawl_StateDB.class b/SillyJirafe.org/bin/org/sillyjirafe/db/Crawl_StateDB.class index 2efa397..a57e70e 100644 Binary files a/SillyJirafe.org/bin/org/sillyjirafe/db/Crawl_StateDB.class and b/SillyJirafe.org/bin/org/sillyjirafe/db/Crawl_StateDB.class differ diff --git a/SillyJirafe.org/bin/org/sillyjirafe/uoapi/ApiKeys.class b/SillyJirafe.org/bin/org/sillyjirafe/uoapi/ApiKeys.class new file mode 100644 index 0000000..bf85544 Binary files /dev/null and b/SillyJirafe.org/bin/org/sillyjirafe/uoapi/ApiKeys.class differ diff --git a/SillyJirafe.org/bin/org/sillyjirafe/uoapi/Out.class b/SillyJirafe.org/bin/org/sillyjirafe/uoapi/Out.class index e67a5e9..a89c3dd 100644 Binary files a/SillyJirafe.org/bin/org/sillyjirafe/uoapi/Out.class and b/SillyJirafe.org/bin/org/sillyjirafe/uoapi/Out.class differ diff --git a/SillyJirafe.org/bin/org/sillyjirafe/uoapi/binds/CodeBergApi.class b/SillyJirafe.org/bin/org/sillyjirafe/uoapi/binds/CodeBergApi.class new file mode 100644 index 0000000..580f618 Binary files /dev/null and b/SillyJirafe.org/bin/org/sillyjirafe/uoapi/binds/CodeBergApi.class differ diff --git a/SillyJirafe.org/elements.db b/SillyJirafe.org/elements.db deleted file mode 100644 index 359b90b..0000000 Binary files a/SillyJirafe.org/elements.db and /dev/null differ diff --git a/SillyJirafe.org/src/org/sillyjirafe/db/Crawl_StateDB.java b/SillyJirafe.org/src/org/sillyjirafe/db/Crawl_StateDB.java index d63a23a..1be2389 100644 --- a/SillyJirafe.org/src/org/sillyjirafe/db/Crawl_StateDB.java +++ b/SillyJirafe.org/src/org/sillyjirafe/db/Crawl_StateDB.java @@ -10,7 +10,7 @@ import java.sql.Statement; public class Crawl_StateDB { String URL = new String(); - String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page) VALUES (?, ?)"; + String insertSql = "INSERT OR IGNORE INTO crawlstates (bind_name, last_page, rnd) VALUES (?, ?, ?)"; Connection connection; public Crawl_StateDB(String BDstr) throws SQLException @@ -26,7 +26,8 @@ public class Crawl_StateDB stmt.execute(""" CREATE TABLE IF NOT EXISTS crawlstates ( bind_name TEXT PRIMARY KEY, - last_page INTEGER NOT NULL DEFAULT 1 + last_page INTEGER NOT NULL DEFAULT 1, + rnd TEXT NOT NULL DEFAULT 'a' ) """); } @@ -57,6 +58,20 @@ public class Crawl_StateDB } } } + 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) @@ -68,6 +83,10 @@ public class Crawl_StateDB ps.executeUpdate(); } } + public void updateletter(String bindName) + { + + } public void Close() throws SQLException { diff --git a/SillyJirafe.org/src/org/sillyjirafe/uoapi/ApiKeys.java b/SillyJirafe.org/src/org/sillyjirafe/uoapi/ApiKeys.java new file mode 100644 index 0000000..6912190 --- /dev/null +++ b/SillyJirafe.org/src/org/sillyjirafe/uoapi/ApiKeys.java @@ -0,0 +1,5 @@ +package org.sillyjirafe.uoapi; + +public class ApiKeys { + +} diff --git a/SillyJirafe.org/src/org/sillyjirafe/uoapi/Out.java b/SillyJirafe.org/src/org/sillyjirafe/uoapi/Out.java index fc8aa8f..ac3af9c 100644 --- a/SillyJirafe.org/src/org/sillyjirafe/uoapi/Out.java +++ b/SillyJirafe.org/src/org/sillyjirafe/uoapi/Out.java @@ -5,6 +5,7 @@ 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; @@ -21,6 +22,7 @@ public class Out { Apis.add(new GitHubApacheApi()); Apis.add(new OpenVerseImagesApi()); Apis.add(new OpenVerseAudiosApi()); + Apis.add(new CodeBergApi()); List bindnames = new ArrayList<>(); diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8c/304781b79aa30011197aae2d8f81f7b0 b/SillyJirafe.org/src/org/sillyjirafe/uoapi/binds/CodeBergApi.java similarity index 70% rename from .metadata/.plugins/org.eclipse.core.resources/.history/8c/304781b79aa30011197aae2d8f81f7b0 rename to SillyJirafe.org/src/org/sillyjirafe/uoapi/binds/CodeBergApi.java index 7408492..28ce7f0 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8c/304781b79aa30011197aae2d8f81f7b0 +++ b/SillyJirafe.org/src/org/sillyjirafe/uoapi/binds/CodeBergApi.java @@ -1,28 +1,28 @@ -package org.sillyjrafe.uoapi.binds; - -import java.util.ArrayList; -import java.util.List; +package org.sillyjirafe.uoapi.binds; import org.json.JSONArray; import org.json.JSONObject; -import org.sillyblahaj.uoapi.Api; -import org.sillyblahaj.uoapi.element; +import org.sillyjirafe.uoapi.Api; +import org.sillyjirafe.uoapi.element; +import java.util.ArrayList; +import java.util.List; -public class GitHubLGPLApi implements Api +public class CodeBergApi implements Api { public String getName() { - return "GitHubLGPLApi"; + return "CadeBergApi"; } public String getURL(int page) { - return "https://api.github.com/search/repositories?q=license:lgpl-3.0&page=" + page; + return "https://codeberg.org/api/v1/repos/search?page=" + page; } public List Parse(String jsonRaw) { List resultats = new ArrayList<>(); + try { JSONObject json = new JSONObject(jsonRaw); JSONArray items = json.getJSONArray("items"); @@ -34,7 +34,7 @@ public class GitHubLGPLApi implements Api String url = repo.getString("html_url"); String licence = repo.getJSONObject("license").getString("spdx_id"); - resultats.add(new element(titre, url, licence, "github", "code")); + resultats.add(new element(titre, url, licence, "codeberg", "code")); } } catch (org.json.JSONException e) { System.out.println("error but continue : " + e.getMessage()); diff --git a/libs/json-20250107.jar b/libs/json-20250107.jar new file mode 100644 index 0000000..17afd9e Binary files /dev/null and b/libs/json-20250107.jar differ diff --git a/libs/sqlite-jdbc-3.53.2.1.jar b/libs/sqlite-jdbc-3.53.2.1.jar new file mode 100644 index 0000000..acff93c Binary files /dev/null and b/libs/sqlite-jdbc-3.53.2.1.jar differ