-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: scrape archwings and companions from wikia (#506)
- Loading branch information
1 parent
5b92fc8
commit bc15c4c
Showing
5 changed files
with
98 additions
and
1 deletion.
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
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,8 @@ | ||
import WikiaDataScraper from '../WikiaDataScraper.mjs'; | ||
import transformWarframe from '../transformers/transformWarframe.mjs'; | ||
|
||
export default class ArchwingScraper extends WikiaDataScraper { | ||
constructor() { | ||
super('https://warframe.fandom.com/wiki/Module:Warframes/data?action=edit', 'Archwing', transformWarframe); | ||
} | ||
} |
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,8 @@ | ||
import WikiaDataScraper from '../WikiaDataScraper.mjs'; | ||
import transformCompanion from '../transformers/transformCompanion.mjs'; | ||
|
||
export default class CompanionScraper extends WikiaDataScraper { | ||
constructor() { | ||
super('https://warframe.fandom.com/wiki/Module:Companions/data?action=edit', 'Companion', transformCompanion); | ||
} | ||
} |
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,36 @@ | ||
/** | ||
* Transform wikia lua companions into usable standardized json | ||
* @param {Object} oldCompanion old companion in lua format | ||
* @param {Record<string, unknown>} imageUrls name-url pairs | ||
* @returns {Promise<WikiaCompanion>} | ||
*/ | ||
export default async (oldCompanion, imageUrls) => { | ||
let newCompanion; | ||
if (!oldCompanion || !oldCompanion.Name) { | ||
return undefined; | ||
} | ||
|
||
try { | ||
const { Image, Mastery, Polarities, Stamina, Introduced, Vaulted, VaultDate, EstimatedVaultDate } = oldCompanion; | ||
const { Name } = oldCompanion; | ||
|
||
newCompanion = { | ||
name: Name, | ||
url: `https://warframe.fandom.com/wiki/${encodeURIComponent( | ||
Name.replace(/\s/g, '_').replace('_Prime', '/Prime') | ||
)}`, | ||
mr: Mastery || 0, | ||
polarities: Polarities, | ||
stamina: Stamina, | ||
introduced: Introduced, | ||
vaulted: Vaulted || undefined, | ||
vaultDate: VaultDate, | ||
estimatedVaultDate: EstimatedVaultDate, | ||
thumbnail: imageUrls?.[Image], | ||
}; | ||
} catch (error) { | ||
console.error(`Error parsing ${oldCompanion.Name}`); | ||
console.error(error); | ||
} | ||
return newCompanion; | ||
}; |
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,37 @@ | ||
import transformPolarity from './transformPolarity.mjs'; | ||
|
||
/** | ||
* Transform wikia lua archwings into usable standardized json | ||
* @param {Object} oldWings old archwing in lua format | ||
* @param {Record<string, unknown>} imageUrls name-url pairs | ||
* @returns {Promise<WikiaArchwing>} | ||
*/ | ||
export default async (oldWings, imageUrls) => { | ||
let newWings; | ||
if (!oldWings || !oldWings.Name) { | ||
return undefined; | ||
} | ||
|
||
try { | ||
const { Image, Mastery, Polarities, Sprint, Introduced, Vaulted } = oldWings; | ||
const { Name } = oldWings; | ||
|
||
newWings = { | ||
name: Name, | ||
url: `https://warframe.fandom.com/wiki/${encodeURIComponent( | ||
Name.replace(/\s/g, '_').replace('_Prime', '/Prime') | ||
)}`, | ||
mr: Mastery || 0, | ||
polarities: Polarities, | ||
sprint: Sprint, | ||
introduced: Introduced, | ||
vaulted: Vaulted || undefined, | ||
thumbnail: imageUrls?.[Image], | ||
}; | ||
newWings = transformPolarity(oldWings, newWings); | ||
} catch (error) { | ||
console.error(`Error parsing ${oldWings.Name}`); | ||
console.error(error); | ||
} | ||
return newWings; | ||
}; |