Skip to content

Commit c557bfe

Browse files
Merge pull request #146 from ZackBoe/steam-search
Steam: use Steam Community SearchApps for title search
2 parents f1f602f + cbef33e commit c557bfe

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

src/api/apis/SteamAPI.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class SteamAPI extends APIModel {
1616
this.plugin = plugin;
1717
this.apiName = 'SteamAPI';
1818
this.apiDescription = 'A free API for all Steam games.';
19-
this.apiUrl = 'http://www.steampowered.com/';
19+
this.apiUrl = 'https://www.steampowered.com/';
2020
this.types = [MediaType.Game];
2121
this.typeMappings = new Map<string, string>();
2222
this.typeMappings.set('game', 'game');
@@ -25,7 +25,7 @@ export class SteamAPI extends APIModel {
2525
async searchByTitle(title: string): Promise<MediaTypeModel[]> {
2626
console.log(`MDB | api "${this.apiName}" queried by Title`);
2727

28-
const searchUrl = `http://api.steampowered.com/ISteamApps/GetAppList/v0002/?format=json`;
28+
const searchUrl = `https://steamcommunity.com/actions/SearchApps/${encodeURIComponent(title)}`;
2929
const fetchData = await requestUrl({
3030
url: searchUrl,
3131
});
@@ -38,26 +38,9 @@ export class SteamAPI extends APIModel {
3838

3939
console.debug(data);
4040

41-
const filteredData = [];
42-
43-
for (const app of data.applist.apps) {
44-
if (
45-
app.name
46-
.normalize('NFD')
47-
.replace(/\p{Diacritic}/gu, '')
48-
.toLowerCase()
49-
.includes(title.toLowerCase())
50-
) {
51-
filteredData.push(app);
52-
}
53-
if (filteredData.length > 20) {
54-
break;
55-
}
56-
}
57-
5841
const ret: MediaTypeModel[] = [];
5942

60-
for (const result of filteredData) {
43+
for (const result of data) {
6144
ret.push(
6245
new GameModel({
6346
type: MediaType.Game,
@@ -76,7 +59,7 @@ export class SteamAPI extends APIModel {
7659
async getById(id: string): Promise<MediaTypeModel> {
7760
console.log(`MDB | api "${this.apiName}" queried by ID`);
7861

79-
const searchUrl = `http://store.steampowered.com/api/appdetails?appids=${encodeURIComponent(id)}&l=en`;
62+
const searchUrl = `https://store.steampowered.com/api/appdetails?appids=${encodeURIComponent(id)}&l=en`;
8063
const fetchData = await requestUrl({
8164
url: searchUrl,
8265
});

0 commit comments

Comments
 (0)