This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from CapitaineJSparrow/feature/game-banana
Add game banana mods
- Loading branch information
Showing
9 changed files
with
131 additions
and
11 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
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,29 @@ | ||
import HttpService from "../services/HttpService"; | ||
import fetch from "node-fetch"; | ||
import cheerio from "cheerio"; | ||
|
||
export type searchProps = [string]; | ||
|
||
export const searchGameBana = async (...args: searchProps) => { | ||
const [name] = args; | ||
const res = await HttpService.searchGameBana(name) as unknown as { _idRow: number }[]; | ||
|
||
if (res.length === 0) { | ||
return; | ||
} | ||
|
||
const url = `https://gamebanana.com/mods/games/${res[0]._idRow}?mid=SubmissionsList&vl[preset]=most_dld&vl%5Border%5D=downloads`; | ||
const modPageContent = await fetch(url).then(r => r.text()).catch(() => ""); | ||
const $ = cheerio.load(modPageContent); | ||
const modsIdentifiers = $("recordCell[class='Identifiers']"); | ||
const modsPreviews = $("recordCell[class='Preview']"); | ||
|
||
return modsIdentifiers.map((i, element) => { | ||
const modElement = $(element).find("a[class='Name']"); | ||
return { | ||
name: modElement.text().trim(), | ||
url: modElement.attr("href"), | ||
cover: $(modsPreviews[i]).find("img").attr("src") | ||
}; | ||
}); | ||
}; |
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
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