Fix wiki renames with redirects
This commit is contained in:
parent
d28e78ce81
commit
9bb69d4dbf
5 changed files with 128 additions and 24 deletions
|
@ -128564,7 +128564,37 @@ Corpse Mob:
|
|||
steam:
|
||||
id: 828460
|
||||
Corpse Party:
|
||||
alias: "Corpse Party: Blood Covered (2016)"
|
||||
files:
|
||||
"<base>/corpseparty.ini":
|
||||
tags:
|
||||
- config
|
||||
when:
|
||||
- os: windows
|
||||
"<base>/save_data":
|
||||
tags:
|
||||
- save
|
||||
when:
|
||||
- os: windows
|
||||
"<root>/userdata/<storeUserId>/251270/remote":
|
||||
tags:
|
||||
- save
|
||||
when:
|
||||
- store: steam
|
||||
gog:
|
||||
id: 1460712231
|
||||
installDir:
|
||||
Corpse Party: {}
|
||||
launch:
|
||||
"<base>/CorpseParty":
|
||||
- when:
|
||||
- os: linux
|
||||
store: steam
|
||||
"<base>/CorpseParty.exe":
|
||||
- when:
|
||||
- os: windows
|
||||
store: steam
|
||||
steam:
|
||||
id: 251270
|
||||
Corpse Party (2021):
|
||||
files:
|
||||
"<winAppData>/CorpseParty":
|
||||
|
@ -128642,6 +128672,8 @@ Corpse Party (2021):
|
|||
- os: windows
|
||||
id:
|
||||
lutris: corpse-party-bloodcovered
|
||||
"Corpse Party: Blood Covered (2016)":
|
||||
alias: Corpse Party
|
||||
"Corpse Party: Blood Covered ...Repeated Fear":
|
||||
alias: Corpse Party (2021)
|
||||
"Corpse Party: Blood Drive":
|
||||
|
@ -224626,6 +224658,35 @@ Fight or Flight:
|
|||
fof1: {}
|
||||
steam:
|
||||
id: 775620
|
||||
Fight the Dragon:
|
||||
files:
|
||||
"<home>/.config/unity3d/3 Sprockets/FightTheDragon":
|
||||
tags:
|
||||
- config
|
||||
when:
|
||||
- os: linux
|
||||
"<home>/AppData/LocalLow/3 Sprockets/FightTheDragon":
|
||||
tags:
|
||||
- save
|
||||
when:
|
||||
- os: windows
|
||||
installDir:
|
||||
FightTheDragon: {}
|
||||
launch:
|
||||
"<base>/FightTheDragon.app":
|
||||
- when:
|
||||
- os: mac
|
||||
store: steam
|
||||
"<base>/FightTheDragon.exe":
|
||||
- when:
|
||||
- os: windows
|
||||
store: steam
|
||||
"<base>/startgame.sh":
|
||||
- when:
|
||||
- os: linux
|
||||
store: steam
|
||||
steam:
|
||||
id: 250560
|
||||
Fight the Horror:
|
||||
installDir:
|
||||
Fight_the_Horror: {}
|
||||
|
|
|
@ -5268,7 +5268,6 @@
|
|||
* [Corpoct](https://www.pcgamingwiki.com/wiki/?curid=144939)
|
||||
* [Corpse Killer - 25th Anniversary Edition](https://www.pcgamingwiki.com/wiki/?curid=139347)
|
||||
* [Corpse of Discovery](https://www.pcgamingwiki.com/wiki/?curid=46713)
|
||||
* [Corpse Party: Blood Covered (2016)](https://www.pcgamingwiki.com/wiki/?curid=183572)
|
||||
* [Corral](https://www.pcgamingwiki.com/wiki/?curid=92716)
|
||||
* [Corridor 15](https://www.pcgamingwiki.com/wiki/?curid=76975)
|
||||
* [Corridor 7: Alien Invasion](https://www.pcgamingwiki.com/wiki/?curid=26687)
|
||||
|
@ -7215,7 +7214,6 @@
|
|||
* [DooM in the Dark 2](https://www.pcgamingwiki.com/wiki/?curid=153095)
|
||||
* [Doom of the Clawn](https://www.pcgamingwiki.com/wiki/?curid=156098)
|
||||
* [Doom Rails](https://www.pcgamingwiki.com/wiki/?curid=41208)
|
||||
* [DOOMBRINGER](https://www.pcgamingwiki.com/wiki/?curid=163148)
|
||||
* [Doomed](https://www.pcgamingwiki.com/wiki/?curid=95057)
|
||||
* [Doomed Kingdoms](https://www.pcgamingwiki.com/wiki/?curid=54977)
|
||||
* [Doomed'n Damned](https://www.pcgamingwiki.com/wiki/?curid=47289)
|
||||
|
@ -9143,7 +9141,6 @@
|
|||
* [Fight or Die](https://www.pcgamingwiki.com/wiki/?curid=56080)
|
||||
* [Fight or Die 2](https://www.pcgamingwiki.com/wiki/?curid=63278)
|
||||
* [Fight Sparring VR](https://www.pcgamingwiki.com/wiki/?curid=64307)
|
||||
* [Fight The Dragon](https://www.pcgamingwiki.com/wiki/?curid=191161)
|
||||
* [Fight the Horror](https://www.pcgamingwiki.com/wiki/?curid=109048)
|
||||
* [Fight This](https://www.pcgamingwiki.com/wiki/?curid=130462)
|
||||
* [Fight wisdom](https://www.pcgamingwiki.com/wiki/?curid=155608)
|
||||
|
|
|
@ -29931,6 +29931,12 @@
|
|||
- description: Launch
|
||||
executable: Livelock.exe
|
||||
251270:
|
||||
cloud:
|
||||
saves:
|
||||
- path: save_data
|
||||
pattern: dummy.dat
|
||||
recursive: true
|
||||
root: gameinstall
|
||||
installDir: Corpse Party
|
||||
launch:
|
||||
- config:
|
||||
|
|
|
@ -36705,6 +36705,17 @@ Corpse Killer - 25th Anniversary Edition:
|
|||
Corpse Mob:
|
||||
pageId: 94405
|
||||
steam: 828460
|
||||
Corpse Party:
|
||||
gog: 1460712231
|
||||
pageId: 34195
|
||||
renamedFrom:
|
||||
- Corpse Party
|
||||
- "Corpse Party: Blood Covered (2016)"
|
||||
steam: 251270
|
||||
templates:
|
||||
- "{{Game data/config|Windows|{{p|game}}\\corpseparty.ini}}"
|
||||
- "{{Game data/saves|Windows|{{p|game}}\\save_data\\}}"
|
||||
- "{{Game data/saves|Steam|{{p|steam}}/userdata/{{p|uid}}/251270/remote/}}"
|
||||
Corpse Party (2021):
|
||||
gog: 1138308214
|
||||
pageId: 172374
|
||||
|
@ -36729,10 +36740,6 @@ Corpse Party (2021):
|
|||
templates:
|
||||
- "{{Game data/config|Windows|{{p|game}}\\grisgris.ini}}"
|
||||
- "{{Game data/saves|Windows|{{p|game}}\\save_data\\*.*}}"
|
||||
"Corpse Party: Blood Covered (2016)":
|
||||
pageId: 183572
|
||||
renamedFrom:
|
||||
- Corpse Party
|
||||
"Corpse Party: Blood Drive":
|
||||
gog: 1771718646
|
||||
pageId: 147874
|
||||
|
@ -41096,11 +41103,6 @@ DOKA 2 GUTS OUT NINJA:
|
|||
DOKA 2 KISHKI EDITION:
|
||||
pageId: 120982
|
||||
steam: 967250
|
||||
DOOMBRINGER:
|
||||
pageId: 163148
|
||||
renamedFrom:
|
||||
- DOOMBRINGER
|
||||
- Doombringer
|
||||
DOOMTANK:
|
||||
pageId: 136846
|
||||
steam: 1087310
|
||||
|
@ -64584,8 +64586,6 @@ Fight Me Bro!:
|
|||
Fight Sparring VR:
|
||||
pageId: 64307
|
||||
steam: 665730
|
||||
Fight The Dragon:
|
||||
pageId: 191161
|
||||
Fight This:
|
||||
pageId: 130462
|
||||
steam: 1037900
|
||||
|
@ -64607,6 +64607,14 @@ Fight or Die 2:
|
|||
Fight or Flight:
|
||||
pageId: 124526
|
||||
steam: 775620
|
||||
Fight the Dragon:
|
||||
pageId: 16274
|
||||
renamedFrom:
|
||||
- Fight The Dragon
|
||||
steam: 250560
|
||||
templates:
|
||||
- "{{Game data/config|Linux|{{p|linuxhome}}/.config/unity3d/3 Sprockets/FightTheDragon}}"
|
||||
- "{{Game data/saves|Windows|{{p|userprofile}}\\AppData\\LocalLow\\3 Sprockets\\FightTheDragon\\}}"
|
||||
Fight the Horror:
|
||||
pageId: 109048
|
||||
steam: 857600
|
||||
|
|
50
src/wiki.rs
50
src/wiki.rs
|
@ -291,7 +291,15 @@ impl WikiCache {
|
|||
match latest {
|
||||
Ok(mut latest) => {
|
||||
latest.renamed_from = cached.renamed_from.clone();
|
||||
self.0.insert(title.to_string(), latest);
|
||||
if let Some(new_title) = latest.new_title.take() {
|
||||
println!(" page {} redirected to '{}'", cached.page_id, &new_title);
|
||||
|
||||
latest.renamed_from.push(title.to_string());
|
||||
self.0.remove(title);
|
||||
self.0.insert(new_title, latest);
|
||||
} else {
|
||||
self.0.insert(title.to_string(), latest);
|
||||
}
|
||||
}
|
||||
Err(Error::PageMissing) => {
|
||||
// Couldn't find it by name, so try again by ID.
|
||||
|
@ -299,23 +307,32 @@ impl WikiCache {
|
|||
// (If they have a redirect, then the recent changes code takes care of it.)
|
||||
let Some(new_title) = get_page_title(cached.page_id).await? else {
|
||||
// Page no longer exists.
|
||||
println!(":: refresh: page no longer exists");
|
||||
println!(" page no longer exists");
|
||||
self.0.remove(title);
|
||||
continue;
|
||||
};
|
||||
|
||||
println!(
|
||||
":: refresh: page {} called '{}' renamed to '{}'",
|
||||
cached.page_id, title, &new_title
|
||||
);
|
||||
println!(" page {} renamed to '{}'", cached.page_id, &new_title);
|
||||
|
||||
if new_title.starts_with("File:") || new_title.starts_with("Company:") {
|
||||
println!(":: refresh: page is no longer a game");
|
||||
println!(" page is no longer a game");
|
||||
self.0.remove(title);
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut latest = WikiCacheEntry::fetch_from_page(new_title.clone()).await?;
|
||||
let mut latest = match WikiCacheEntry::fetch_from_page(new_title.clone()).await {
|
||||
Ok(x) => x,
|
||||
Err(Error::PageMissing) => {
|
||||
println!(" page does not exist");
|
||||
self.0.remove(title);
|
||||
continue;
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(e);
|
||||
}
|
||||
};
|
||||
|
||||
let new_title = latest.new_title.take().unwrap_or(new_title);
|
||||
|
||||
let mut cached = self.0[title].clone();
|
||||
cached.renamed_from.push(title.clone());
|
||||
|
@ -360,6 +377,10 @@ pub struct WikiCacheEntry {
|
|||
pub steam_side: BTreeSet<u32>,
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
pub templates: Vec<String>,
|
||||
|
||||
/// This will be set after resolving a redirect.
|
||||
#[serde(skip)]
|
||||
pub new_title: Option<String>,
|
||||
}
|
||||
|
||||
impl WikiCacheEntry {
|
||||
|
@ -370,7 +391,12 @@ impl WikiCacheEntry {
|
|||
};
|
||||
|
||||
let wiki = make_client().await?;
|
||||
let params = wiki.params_into(&[("action", "parse"), ("prop", "wikitext"), ("page", &article)]);
|
||||
let params = wiki.params_into(&[
|
||||
("action", "parse"),
|
||||
("prop", "wikitext"),
|
||||
("page", &article),
|
||||
("redirects", "1"),
|
||||
]);
|
||||
|
||||
let res = wiki
|
||||
.get_query_api_json_all(¶ms)
|
||||
|
@ -382,6 +408,12 @@ impl WikiCacheEntry {
|
|||
}
|
||||
|
||||
out.page_id = res["parse"]["pageid"].as_u64().ok_or(Error::WikiData("parse.pageid"))?;
|
||||
|
||||
let received_title = res["parse"]["title"].as_str().ok_or(Error::WikiData("parse.title"))?;
|
||||
if received_title != article {
|
||||
out.new_title = Some(received_title.to_string());
|
||||
}
|
||||
|
||||
let raw_wikitext = res["parse"]["wikitext"]["*"]
|
||||
.as_str()
|
||||
.ok_or(Error::WikiData("parse.wikitext"))?;
|
||||
|
|
Reference in a new issue