Edit CF indexer
This commit is contained in:
parent
74f8f687cf
commit
aa5505d693
2
.github/workflows/rust.yml
vendored
2
.github/workflows/rust.yml
vendored
@ -19,4 +19,4 @@ jobs:
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
||||
run: cargo test --verbose
|
||||
@ -6,7 +6,7 @@ pub async fn mod_editor_get(hb: web::Data<Handlebars<'_>>) -> HttpResponse {
|
||||
let data = json!({
|
||||
"name": "Handlebars"
|
||||
});
|
||||
let body = hb.render("mod_editor", &data).unwrap();
|
||||
let body = hb.render("mod-page", &data).unwrap();
|
||||
|
||||
HttpResponse::Ok().body(body)
|
||||
}
|
||||
|
||||
@ -50,6 +50,7 @@ struct CurseForgeMod {
|
||||
game_version_latest_files: Vec<CurseVersion>,
|
||||
date_created: String,
|
||||
date_modified: String,
|
||||
game_slug: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
@ -180,12 +181,27 @@ pub async fn index_mods() -> Result<(), Box<dyn Error>>{
|
||||
|
||||
info!("Indexing curseforge mods!");
|
||||
|
||||
let body = reqwest::get("https://addons-ecs.forgesvc.net/api/v2/addon/search?categoryId=0&gameId=432&index=0&pageSize=10000§ionId=6&sort=5")
|
||||
.await?.text().await?;
|
||||
let mut indexing_complete = false;
|
||||
let mut current_mod_id = 0;
|
||||
let mut consecutive_returns = 0;
|
||||
|
||||
let curseforge_mods: Vec<CurseForgeMod> = serde_json::from_str(&body)?;
|
||||
while !(consecutive_returns > 1000 && current_mod_id > 300000) {
|
||||
current_mod_id += 1;
|
||||
info!("Requesting mod with id {} from CurseForge!", current_mod_id);
|
||||
|
||||
let body = reqwest::get(&format!("https://addons-ecs.forgesvc.net/api/v2/addon/{}", current_mod_id))
|
||||
.await?.text().await?;
|
||||
|
||||
if body.is_empty() {
|
||||
consecutive_returns += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
let curseforge_mod : CurseForgeMod = serde_json::from_str(&body)?;
|
||||
consecutive_returns == 0;
|
||||
|
||||
if curseforge_mod.game_slug != "minecraft" { continue; }
|
||||
|
||||
for curseforge_mod in curseforge_mods {
|
||||
let mut mod_game_versions = vec![];
|
||||
|
||||
let mut using_forge = false;
|
||||
@ -298,7 +314,7 @@ pub async fn index_mods() -> Result<(), Box<dyn Error>>{
|
||||
updated: curseforge_mod.date_modified.chars().filter(|c| c.is_ascii_digit()).collect::<String>().parse()?,
|
||||
latest_version,
|
||||
empty: String::from("{}{}{}"),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
//Write Indexes
|
||||
|
||||
@ -132,7 +132,7 @@
|
||||
align-items: center;
|
||||
|
||||
margin: 30px auto 0 0;
|
||||
width: 20%;
|
||||
width: 15%;
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user