0.0.1.1
This commit is contained in:
parent
894ac6525e
commit
ac26a8a4c0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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
|
||||
{
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.sillyjirafe.uoapi;
|
||||
|
||||
public class ApiKeys {
|
||||
|
||||
}
|
||||
@@ -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<String> bindnames = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.sillyjirafe.uoapi.binds;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.sillyjirafe.uoapi.Api;
|
||||
import org.sillyjirafe.uoapi.element;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CodeBergApi implements Api
|
||||
{
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "CadeBergApi";
|
||||
}
|
||||
|
||||
public String getURL(int page) {
|
||||
return "https://codeberg.org/api/v1/repos/search?page=" + page;
|
||||
}
|
||||
|
||||
public List<element> Parse(String jsonRaw) {
|
||||
List<element> resultats = new ArrayList<>();
|
||||
|
||||
|
||||
try {
|
||||
JSONObject json = new JSONObject(jsonRaw);
|
||||
JSONArray items = json.getJSONArray("items");
|
||||
|
||||
for (int i = 0; i < items.length(); i++) {
|
||||
JSONObject repo = items.getJSONObject(i);
|
||||
|
||||
String titre = repo.getString("full_name");
|
||||
String url = repo.getString("html_url");
|
||||
String licence = repo.getJSONObject("license").getString("spdx_id");
|
||||
|
||||
resultats.add(new element(titre, url, licence, "codeberg", "code"));
|
||||
}
|
||||
} catch (org.json.JSONException e) {
|
||||
System.out.println("error but continue : " + e.getMessage());
|
||||
}
|
||||
|
||||
return resultats;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user