steamutils 1.1.89 → 1.1.90
Sign up to get free protection for your applications and to get access to all the features.
- package/.idea/steamutils.iml +1 -1
- package/.idea/vcs.xml +1 -1
- package/index.js +53 -37
- package/package.json +1 -1
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
package/.idea/steamutils.iml
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
<module type="WEB_MODULE" version="4">
|
3
3
|
<component name="NewModuleRootManager">
|
4
4
|
<content url="file://$MODULE_DIR$">
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
6
5
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
7
7
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
8
8
|
</content>
|
9
9
|
<orderEntry type="inheritedJdk" />
|
package/.idea/vcs.xml
CHANGED
package/index.js
CHANGED
@@ -1506,6 +1506,7 @@ class SteamUser {
|
|
1506
1506
|
let response = null
|
1507
1507
|
let retry = 10
|
1508
1508
|
let checkTooManyRequest = false
|
1509
|
+
|
1509
1510
|
while (--retry) {
|
1510
1511
|
const config = {
|
1511
1512
|
baseURL: SteamcommunityURL,
|
@@ -1535,50 +1536,65 @@ class SteamUser {
|
|
1535
1536
|
response = await axios.request(config)
|
1536
1537
|
|
1537
1538
|
this._cookies.setCookies(response.headers["set-cookie"])
|
1538
|
-
if (response.status === 302) {
|
1539
|
-
redirectURL = response.headers.location
|
1540
1539
|
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1540
|
+
switch (response.status) {
|
1541
|
+
case 302: {
|
1542
|
+
redirectURL = response.headers.location
|
1543
|
+
|
1544
|
+
if (redirectURL?.startsWith('https://steamcommunity.com/id/')) {
|
1545
|
+
const customURL = redirectURL.split('/')[4];
|
1546
|
+
if (customURL) {
|
1547
|
+
this._myProfile = `id/${customURL}`
|
1548
|
+
}
|
1549
|
+
} else if (redirectURL?.startsWith('https://steamcommunity.com/login/')) {
|
1550
|
+
console.error('Login first', this._steamid_user)
|
1551
|
+
return null
|
1545
1552
|
}
|
1546
|
-
} else if (redirectURL?.startsWith('https://steamcommunity.com/login/')) {
|
1547
|
-
console.error('Login first', this._steamid_user)
|
1548
|
-
return null
|
1549
|
-
}
|
1550
1553
|
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1554
|
+
console.log(`Redirect ${config.url} to ${redirectURL}`)
|
1555
|
+
break
|
1556
|
+
}
|
1557
|
+
case 200: {
|
1558
|
+
if (response.data && typeof response.data === 'string') {
|
1559
|
+
response._$ = function () {
|
1560
|
+
return cheerio.load(response.data
|
1561
|
+
.replaceAll(/[\t\n\r]/gi, '')
|
1562
|
+
.trim())
|
1563
|
+
}
|
1558
1564
|
}
|
1565
|
+
return response
|
1566
|
+
break
|
1559
1567
|
}
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
} else if (response.status === 401) {
|
1567
|
-
console.log('Unauthorized', config.url)
|
1568
|
-
if (params.method.toUpperCase() === 'POST') {
|
1569
|
-
config.headers['Content-Type'] = config.headers['content-type'] = 'multipart/form-data'
|
1570
|
-
retry = 1
|
1568
|
+
case 429: {
|
1569
|
+
console.log('Too Many Requests', config.url)
|
1570
|
+
tooManyRequestTimestamp = new Date().getTime()
|
1571
|
+
checkTooManyRequest = true
|
1572
|
+
await sleep(30000)
|
1573
|
+
break
|
1571
1574
|
}
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1575
|
+
case 401: {
|
1576
|
+
console.log('Unauthorized', config.url)
|
1577
|
+
if (params.method.toUpperCase() === 'POST') {
|
1578
|
+
config.headers['Content-Type'] = config.headers['content-type'] = 'multipart/form-data'
|
1579
|
+
retry = 1
|
1580
|
+
}
|
1581
|
+
break
|
1582
|
+
}
|
1583
|
+
case 400: {
|
1584
|
+
console.log('Error', response.status, config.url)
|
1585
|
+
if (params.method.toUpperCase() === 'POST') {
|
1586
|
+
config.headers['Content-Type'] = config.headers['content-type'] = 'application/x-www-form-urlencoded'
|
1587
|
+
retry = 1
|
1588
|
+
}
|
1589
|
+
break
|
1590
|
+
}
|
1591
|
+
case 500: {
|
1592
|
+
console.log(response.status, response.statusText, config.url, response.data)
|
1593
|
+
break
|
1594
|
+
}
|
1595
|
+
default: {
|
1596
|
+
console.log(response.status, config.url);
|
1577
1597
|
}
|
1578
|
-
} else if (response.status === 500) {
|
1579
|
-
console.log(response.status, response.statusText, config.url, response.data)
|
1580
|
-
} else {
|
1581
|
-
console.log(response.status, config.url);
|
1582
1598
|
}
|
1583
1599
|
}
|
1584
1600
|
return response
|
package/package.json
CHANGED