-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
100 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,10 @@ name = "mediawiki" | |
version = "0.0.1" | ||
authors = ["Peter Atashian <[email protected]>"] | ||
license = "MIT/Apache-2.0" | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
cookie = "0.15" | ||
cookie = "0.17" | ||
regex = "1.0" | ||
reqwest = { version = "0.11", features = ["blocking", "multipart"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use mediawiki::{oredict::Oredict, tilesheet::Tilesheet, Mediawiki}; | ||
use serde_json::Value; | ||
use std::fs; | ||
|
||
fn export() { | ||
let mw = Mediawiki::login_path("ftb.json").unwrap(); | ||
let tiles = mw | ||
.query_tiles(None) | ||
.into_iter() | ||
.map(|tile| tile.unwrap()) | ||
.collect::<Vec<_>>(); | ||
fs::write("tiles.json", Value::Array(tiles.clone()).to_string()).unwrap(); | ||
let sheets = mw | ||
.query_sheets() | ||
.into_iter() | ||
.map(|sheet| sheet.unwrap()) | ||
.collect::<Vec<_>>(); | ||
fs::write("sheets.json", Value::Array(sheets).to_string()).unwrap(); | ||
let ores = mw | ||
.query_ores(None) | ||
.into_iter() | ||
.map(|ore| ore.unwrap()) | ||
.collect::<Vec<_>>(); | ||
fs::write("ores.json", Value::Array(ores).to_string()).unwrap(); | ||
let translations = tiles | ||
.into_iter() | ||
.flat_map(|tile| { | ||
let id = tile["id"].as_i64().unwrap(); | ||
mw.query_tile_translations(id) | ||
.into_iter() | ||
.map(|trans| trans.unwrap()) | ||
}) | ||
.collect::<Vec<_>>(); | ||
fs::write("translations.json", Value::Array(translations).to_string()).unwrap(); | ||
} | ||
fn main() { | ||
export(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use mediawiki::{tilesheet::Tilesheet, Mediawiki}; | ||
use std::env::args; | ||
|
||
fn purge(mod_name: &str) { | ||
let mw = Mediawiki::login_path("ftb.json").unwrap(); | ||
let todelete: Vec<String> = mw | ||
.query_tiles(Some(mod_name)) | ||
.into_iter() | ||
.map(|tile| { | ||
let tile = tile.unwrap(); | ||
let tile = tile.as_object().unwrap(); | ||
tile["id"].as_i64().unwrap().to_string() | ||
}) | ||
.collect(); | ||
let token = mw.get_token().unwrap(); | ||
for chunk in todelete.chunks(100) { | ||
let blob = chunk.join("|"); | ||
mw.delete_tiles(&token, &blob, Some("Purging tiles")) | ||
.unwrap(); | ||
} | ||
mw.delete_sheet(&token, mod_name, Some("Purging tilesheet")) | ||
.unwrap(); | ||
} | ||
fn main() { | ||
let name = args().nth(1).unwrap(); | ||
purge(&name); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters