Skip to content

Commit 00e29db

Browse files
authored
Added game developers and publishers as properties (#59)
1 parent 1bdc0c6 commit 00e29db

8 files changed

+180
-6
lines changed

README.md

+70
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,76 @@ The name of the Notion property to set the Steam Deck Compatibility score in.
529529
| `string` | `"Steam Deck Compatibility"` | A valid Notion property name | Yes |
530530
</details>
531531

532+
<details>
533+
<summary><code>gameDevelopers</code></summary>
534+
535+
The developer(s) of the game. The database field in Notion must be of type `Multi-select`.
536+
537+
| Type | Default value | Possible values | Required |
538+
|---|---|---|---|
539+
| `object` | See item below | See sections below | No |
540+
541+
```json
542+
"gameDevelopers": {
543+
"enabled": true,
544+
"notionProperty": "Developers"
545+
}
546+
```
547+
548+
<h3>Possible values</h3>
549+
550+
<h4><code>enabled</code></h4>
551+
552+
Whether or not the developer(s) of the game should be set in the database.
553+
554+
| Type | Default value | Possible values | Required |
555+
|---|---|---|---|
556+
| `boolean` | `true` | `true` or `false` | Yes |
557+
558+
<h4><code>notionProperty</code></h4>
559+
560+
The name of the Notion property to set the developer(s) in.
561+
562+
| Type | Default value | Possible values | Required |
563+
|---|---|---|---|
564+
| `string` | `"Developers"` | A valid Notion property name | Yes |
565+
</details>
566+
567+
<details>
568+
<summary><code>gamePublishers</code></summary>
569+
570+
The publisher(s) of the game. The database field in Notion must be of type `Multi-select`.
571+
572+
| Type | Default value | Possible values | Required |
573+
|---|---|---|---|
574+
| `object` | See item below | See sections below | No |
575+
576+
```json
577+
"gamePublishers": {
578+
"enabled": true,
579+
"notionProperty": "Publishers"
580+
}
581+
```
582+
583+
<h3>Possible values</h3>
584+
585+
<h4><code>enabled</code></h4>
586+
587+
Whether or not the publisher(s) of the game should be set in the database.
588+
589+
| Type | Default value | Possible values | Required |
590+
|---|---|---|---|
591+
| `boolean` | `true` | `true` or `false` | Yes |
592+
593+
<h4><code>notionProperty</code></h4>
594+
595+
The name of the Notion property to set the publisher(s) in.
596+
597+
| Type | Default value | Possible values | Required |
598+
|---|---|---|---|
599+
| `string` | `"Publishers"` | A valid Notion property name | Yes |
600+
</details>
601+
532602
## Related projects
533603

534604
You can get a list of all games you own on Steam, Epic Games or GOG using the [Steam App ID Finder](https://github.com/NikkelM/Steam-App-ID-Finder). This project also includes a utility to get the Steam App IDs from just a list of game names.

config.default.json

+8
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
"steamDeckCompatibility": {
5050
"enabled": true,
5151
"notionProperty": "Steam Deck Compatibility"
52+
},
53+
"gameDevelopers": {
54+
"enabled": true,
55+
"notionProperty": "Developers"
56+
},
57+
"gamePublishers": {
58+
"enabled": true,
59+
"notionProperty": "Publishers"
5260
}
5361
}
5462
}

config.schema.json

+58
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@
8686
"steamDeckCompatibility": {
8787
"enabled": true,
8888
"notionProperty": "Steam Deck Compatibility"
89+
},
90+
"gameDevelopers": {
91+
"enabled": true,
92+
"notionProperty": "Developers"
93+
},
94+
"gamePublishers": {
95+
"enabled": true,
96+
"notionProperty": "Publishers"
8997
}
9098
},
9199
"additionalProperties": false,
@@ -388,6 +396,56 @@
388396
"enabled",
389397
"notionProperty"
390398
]
399+
},
400+
"gameDevelopers": {
401+
"description": "The developer(s) of the game. The database field in Notion must be of type \"Multi-select\".",
402+
"type": "object",
403+
"default": {
404+
"enabled": true,
405+
"notionProperty": "Developers"
406+
},
407+
"additionalProperties": false,
408+
"properties": {
409+
"enabled": {
410+
"description": "Whether or not the developer(s) of the game should be set in the database.",
411+
"type": "boolean",
412+
"default": true
413+
},
414+
"notionProperty": {
415+
"description": "The name of the Notion property to set the developer(s) in.",
416+
"type": "string",
417+
"default": "Developers"
418+
}
419+
},
420+
"required": [
421+
"enabled",
422+
"notionProperty"
423+
]
424+
},
425+
"gamePublishers": {
426+
"description": "The publisher(s) of the game. The database field in Notion must be of type \"Multi-select\".",
427+
"type": "object",
428+
"default": {
429+
"enabled": true,
430+
"notionProperty": "Publishers"
431+
},
432+
"additionalProperties": false,
433+
"properties": {
434+
"enabled": {
435+
"description": "Whether or not the publisher(s) of the game should be set in the database.",
436+
"type": "boolean",
437+
"default": true
438+
},
439+
"notionProperty": {
440+
"description": "The name of the Notion property to set the publisher(s) in.",
441+
"type": "string",
442+
"default": "Publishers"
443+
}
444+
},
445+
"required": [
446+
"enabled",
447+
"notionProperty"
448+
]
391449
}
392450
}
393451
}

js/gameProperties.js

+37-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ export async function getGameProperties(appInfoDirect, appInfoSteamUser, appInfo
4141
case "steamDeckCompatibility":
4242
outputProperties = getSteamDeckCompatibility(propertyValue, appInfoSteamUser, outputProperties);
4343
break;
44+
case "gameDevelopers":
45+
outputProperties = await getGameDevelopers(propertyValue, appInfoDirect, outputProperties);
46+
break;
47+
case "gamePublishers":
48+
outputProperties = await getGamePublishers(propertyValue, appInfoDirect, outputProperties);
49+
break;
4450
}
4551
}
4652

@@ -290,4 +296,34 @@ function getSteamDeckCompatibility(steamDeckCompatibilityProperty, appInfoSteamU
290296
};
291297

292298
return outputProperties;
293-
}
299+
}
300+
301+
function getGameDevelopers(developerProperty, appInfoDirect, outputProperties) {
302+
if (!developerProperty.enabled || !appInfoDirect.developers) { return outputProperties; }
303+
304+
// Output property is multi-select, as games can have multiple developers in the API
305+
outputProperties[developerProperty.notionProperty] = {
306+
"multi_select": appInfoDirect.developers.map((developer) => {
307+
return {
308+
"name": developer
309+
}
310+
})
311+
};
312+
313+
return outputProperties;
314+
}
315+
316+
function getGamePublishers(publisherProperty, appInfoDirect, outputProperties) {
317+
if (!publisherProperty.enabled || !appInfoDirect.publishers) { return outputProperties; }
318+
319+
// Output property is multi-select, as games can have multiple publishers in the API
320+
outputProperties[publisherProperty.notionProperty] = {
321+
"multi_select": appInfoDirect.publishers.map((publisher) => {
322+
return {
323+
"name": publisher
324+
}
325+
})
326+
};
327+
328+
return outputProperties;
329+
}

js/steamAPI.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function getSteamAppInfoDirect(appId, retryCount = 0) {
3636
// Gets app info from the SteamUser API
3737
// Does not offer all info that the Steam store API does
3838
export async function getSteamAppInfoSteamUser(appIds) {
39-
console.log(`\nGetting app info from SteamUser API for ${appIds.length} games...\n`);
39+
console.log(`\nGetting app info from the SteamUser API for ${appIds.length} games...\n`);
4040

4141
return new Promise(async (resolve) => {
4242
// Passing true as the third argument automatically requests access tokens, which are required for some apps

js/utils.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ function isStoreAPIRequired() {
8585
CONFIG.gameProperties.coverImage?.enabled ||
8686
CONFIG.gameProperties.releaseDate?.enabled ||
8787
CONFIG.gameProperties.gameDescription?.enabled ||
88-
CONFIG.gameProperties.gamePrice?.enabled
88+
CONFIG.gameProperties.gamePrice?.enabled ||
89+
CONFIG.gameProperties.gameDevelopers?.enabled ||
90+
CONFIG.gameProperties.gamePublishers?.enabled
8991
)
9092
}
9193

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "notion-steam-api-integration",
33
"type": "module",
4-
"version": "1.6.0",
4+
"version": "1.7.0",
55
"description": "Notion integration to fetch data from the Steam API and populate a database given Steam App ID's.",
66
"main": "index.js",
77
"dependencies": {

0 commit comments

Comments
 (0)