Skip to content

Commit 2a1f725

Browse files
committed
Added output language as configuration property
1 parent 071d373 commit 2a1f725

6 files changed

Lines changed: 75 additions & 5 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ The two letter market codes for which to fetch games. The script will run once f
5858
| `array` | `["US"]` | `"US"`, `"DZ"`, `"AR"`, `"AU"`, `"AT"`, `"BH"`, `"BD"`, `"BE"`, `"BR"`, `"BG"`, `"CA"`, `"CL"`, `"CN"`, `"CO"`, `"CR"`, `"HR"`, `"CY"`, `"CZ"`, `"DK"`, `"EG"`, `"EE"`, `"FI"`, `"FR"`, `"DE"`, `"GR"`, `"GT"`, `"HK"`, `"HU"`, `"IS"`, `"IN"`, `"ID"`, `"IQ"`, `"IE"`, `"IL"`, `"IT"`, `"JP"`, `"JO"`, `"KZ"`, `"KE"`, `"KW"`, `"LV"`, `"LB"`, `"LI"`, `"LT"`, `"LU"`, `"MY"`, `"MT"`, `"MR"`, `"MX"`, `"MA"`, `"NL"`, `"NZ"`, `"NG"`, `"NO"`, `"OM"`, `"PK"`, `"PE"`, `"PH"`, `"PL"`, `"PT"`, `"QA"`, `"RO"`, `"RU"`, `"SA"`, `"RS"`, `"SG"`, `"SK"`, `"SI"`, `"ZA"`, `"KR"`, `"ES"`, `"SE"`, `"CH"`, `"TW"`, `"TH"`, `"TT"`, `"TN"`, `"TR"`, `"UA"`, `"AE"`, `"GB"`, `"VN"`, `"YE"`, `"LY"`, `"LK"`, `"UY"`, `"VE"`, `"AF"`, `"AX"`, `"AL"`, `"AS"`, `"AO"`, `"AI"`, `"AQ"`, `"AG"`, `"AM"`, `"AW"`, `"BO"`, `"BQ"`, `"BA"`, `"BW"`, `"BV"`, `"IO"`, `"BN"`, `"BF"`, `"BI"`, `"KH"`, `"CM"`, `"CV"`, `"KY"`, `"CF"`, `"TD"`, `"TL"`, `"DJ"`, `"DM"`, `"DO"`, `"EC"`, `"SV"`, `"GQ"`, `"ER"`, `"ET"`, `"FK"`, `"FO"`, `"FJ"`, `"GF"`, `"PF"`, `"TF"`, `"GA"`, `"GM"`, `"GE"`, `"GH"`, `"GI"`, `"GL"`, `"GD"`, `"GP"`, `"GU"`, `"GG"`, `"GN"`, `"GW"`, `"GY"`, `"HT"`, `"HM"`, `"HN"`, `"AZ"`, `"BS"`, `"BB"`, `"BY"`, `"BZ"`, `"BJ"`, `"BM"`, `"BT"`, `"KM"`, `"CG"`, `"CD"`, `"CK"`, `"CX"`, `"CC"`, `"CI"`, `"CW"`, `"JM"`, `"SJ"`, `"JE"`, `"KI"`, `"KG"`, `"LA"`, `"LS"`, `"LR"`, `"MO"`, `"MK"`, `"MG"`, `"MW"`, `"IM"`, `"MH"`, `"MQ"`, `"MU"`, `"YT"`, `"FM"`, `"MD"`, `"MN"`, `"MS"`, `"MZ"`, `"MM"`, `"NA"`, `"NR"`, `"NP"`, `"MV"`, `"ML"`, `"NC"`, `"NI"`, `"NE"`, `"NU"`, `"NF"`, `"PW"`, `"PS"`, `"PA"`, `"PG"`, `"PY"`, `"RE"`, `"RW"`, `"BL"`, `"MF"`, `"WS"`, `"ST"`, `"SN"`, `"MP"`, `"PN"`, `"SX"`, `"SB"`, `"SO"`, `"SC"`, `"SL"`, `"GS"`, `"SH"`, `"KN"`, `"LC"`, `"PM"`, `"VC"`, `"TJ"`, `"TZ"`, `"TG"`, `"TK"`, `"TO"`, `"TM"`, `"TC"`, `"TV"`, `"UM"`, `"UG"`, `"VI"`, `"VG"`, `"WF"`, `"EH"`, `"ZM"`, `"ZW"`, `"UZ"`, `"VU"`, `"SR"`, `"SZ"`, `"AD"`, `"MC"`, `"SM"`, `"ME"`, `"VA"`, `"NEUTRAL"` | Yes, at least one market code. |
5959
</details>
6060

61+
<details>
62+
<summary><code>language</code></summary>
63+
64+
The language to use when fetching game properties. Properties such as the game description will be in this language.
65+
66+
| Type | Default value | Possible values | Required |
67+
| --- | --- | --- | --- |
68+
| `string` | `en-us` | `"es-ar"`, `"pt-br"`, `"en-ca"`, `"fr-ca"`, `"es-cl"`, `"es-co"`, `"es-mx"`, `"en-us"`, `"nl-be"`, `"fr-be"`, `"cs-cz"`, `"da-dk"`, `"de-de"`, `"es-es"`, `"fr-fr"`, `"en-ie"`, `"it-it"`, `"hu-hu"`, `"nl-nl"`, `"nb-no"`, `"de-at"`, `"pl-pl"`, `"pt-pt"`, `"de-ch"`, `"sk-sk"`, `"fr-ch"`, `"fi-fi"`, `"sv-se"`, `"en-gb"`, `"el-gr"`, `"ru-ru"`, `"en-au"`, `"en-hk"`, `"en-in"`, `"id-id"`, `"en-my"`, `"en-nz"`, `"en-ph"`, `"en-sg"`, `"vi-vn"`, `"th-th"`, `"ko-kr"`, `"zh-cn"`, `"zh-tw"`, `"ja-jp"`, `"zh-hk"`, `"en-za"`, `"tr-tr"`, `"he-il"`, `"ar-ae"`, `"ar-sa"` | Yes |
69+
</details>
70+
6171
<details>
6272
<summary><code>fetchConsole</code></summary>
6373

config.default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"markets": [
44
"US"
55
],
6+
"language": "en-us",
67
"fetchConsole": true,
78
"fetchPC": true,
89
"fetchEAPlay": true,

config.schema.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,64 @@
267267
"additionalItems": false,
268268
"uniqueItems": true
269269
},
270+
"language": {
271+
"description": "The language to use when fetching game properties. Properties such as the game description will be in this language.",
272+
"type": "string",
273+
"default": "en-us",
274+
"enum": [
275+
"es-ar",
276+
"pt-br",
277+
"en-ca",
278+
"fr-ca",
279+
"es-cl",
280+
"es-co",
281+
"es-mx",
282+
"en-us",
283+
"nl-be",
284+
"fr-be",
285+
"cs-cz",
286+
"da-dk",
287+
"de-de",
288+
"es-es",
289+
"fr-fr",
290+
"en-ie",
291+
"it-it",
292+
"hu-hu",
293+
"nl-nl",
294+
"nb-no",
295+
"de-at",
296+
"pl-pl",
297+
"pt-pt",
298+
"de-ch",
299+
"sk-sk",
300+
"fr-ch",
301+
"fi-fi",
302+
"sv-se",
303+
"en-gb",
304+
"el-gr",
305+
"ru-ru",
306+
"en-au",
307+
"en-hk",
308+
"en-in",
309+
"id-id",
310+
"en-my",
311+
"en-nz",
312+
"en-ph",
313+
"en-sg",
314+
"vi-vn",
315+
"th-th",
316+
"ko-kr",
317+
"zh-cn",
318+
"zh-tw",
319+
"ja-jp",
320+
"zh-hk",
321+
"en-za",
322+
"tr-tr",
323+
"he-il",
324+
"ar-ae",
325+
"ar-sa"
326+
]
327+
},
270328
"fetchConsole": {
271329
"description": "Whether or not to fetch games available for console Game Pass.",
272330
"type": "boolean",
@@ -622,6 +680,7 @@
622680
],
623681
"required": [
624682
"markets",
683+
"language",
625684
"outputFormat",
626685
"includedProperties"
627686
],

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async function fetchGameIDs(passType, market) {
101101
}
102102

103103
console.log(`Fetching ${passType} Game Pass game ID's for market "${market}"...`);
104-
let gameIds = await fetch(`https://catalog.gamepass.com/sigls/v2?id=${APIIds[passType]}&language=en-us&market=${market}`)
104+
let gameIds = await fetch(`https://catalog.gamepass.com/sigls/v2?id=${APIIds[passType]}&language=${CONFIG.language}&market=${market}`)
105105
.then((response) => response.json())
106106
.then((data) => data.filter((entry) => entry.id).map((entry) => entry.id));
107107

@@ -110,7 +110,7 @@ async function fetchGameIDs(passType, market) {
110110

111111
async function fetchGameProperties(gameIds, passType, market) {
112112
console.log(`Fetching game properties for ${gameIds.length} ${passType} games for market "${market}"...`);
113-
return await fetch(`https://displaycatalog.mp.microsoft.com/v7.0/products?bigIds=${gameIds}&market=${market}&languages=en-us`)
113+
return await fetch(`https://displaycatalog.mp.microsoft.com/v7.0/products?bigIds=${gameIds}&market=${market}&languages=${CONFIG.language}`)
114114
.then((response) => response.json())
115115
.then((data) => {
116116
if (CONFIG.keepCompleteProperties) {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "game-pass-api",
33
"type": "module",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"description": "",
66
"main": "index.js",
77
"dependencies": {

0 commit comments

Comments
 (0)