steamutils 1.5.24 → 1.5.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +97 -89
- package/package.json +1 -1
- package/utils.js +1248 -1234
package/index.js
CHANGED
@@ -7,7 +7,7 @@ import SteamID from "steamid";
|
|
7
7
|
import URL from "url";
|
8
8
|
import Url from "url-parse";
|
9
9
|
import qs from "qs";
|
10
|
-
import { console_log, downloadImage, getCleanObject, getImageSize, JSON_parse, JSON_stringify, removeSpaceKeys, secretAsBuffer, sleep } from "./utils.js";
|
10
|
+
import { console_log, downloadImage, formatMarketHistoryDate, getCleanObject, getImageSize, JSON_parse, JSON_stringify, removeSpaceKeys, secretAsBuffer, sleep } from "./utils.js";
|
11
11
|
import { Header, request } from "./axios.js";
|
12
12
|
import { getTableHasHeaders, querySelectorAll, table2json } from "./cheerio.js";
|
13
13
|
import { getJSObjectFronXML } from "./xml2json.js";
|
@@ -6261,110 +6261,118 @@ export default class SteamUser {
|
|
6261
6261
|
const result = await this._httpRequestAjax({
|
6262
6262
|
url: `market/mylistings/render/?count=100`,
|
6263
6263
|
});
|
6264
|
+
|
6264
6265
|
if (result instanceof ResponseError) {
|
6265
6266
|
return result;
|
6266
6267
|
}
|
6268
|
+
|
6267
6269
|
const data = result?.data;
|
6268
|
-
if (data?.success
|
6269
|
-
|
6270
|
-
const list = [];
|
6271
|
-
$(".market_listing_row").each(function () {
|
6272
|
-
try {
|
6273
|
-
const $1 = $(this);
|
6274
|
-
const [sElementPrefix, listingid, appid, contextid, itemid] = $1
|
6275
|
-
.find(".market_listing_cancel_button > a")
|
6276
|
-
.attr("href")
|
6277
|
-
.split("(")[1]
|
6278
|
-
.split(")")[0]
|
6279
|
-
.split(",")
|
6280
|
-
.map((r) => r.trim().replaceAll(`'`, "").replaceAll(`"`, ""));
|
6281
|
-
const image = $1.find(`#mylisting_${listingid}_image`).attr("src");
|
6282
|
-
const buyer_pays_price = StringUtils.cleanSpace($1.find(`.market_listing_price span[title="This is the price the buyer pays."]`).text().replaceAll(`(`, "").replaceAll(`)`, ""));
|
6283
|
-
const receive_price = StringUtils.cleanSpace($1.find(`.market_listing_price span[title="This is how much you will receive."]`).text().replaceAll(`(`, "").replaceAll(`)`, ""));
|
6284
|
-
const item_name = $1.find(".market_listing_item_name_link").text() || $1.find(".market_listing_item_name").text();
|
6285
|
-
const game_name = $1.find(".market_listing_game_name").text();
|
6286
|
-
const date_combined = StringUtils.cleanSpace($1.find(".market_listing_game_name + .market_listing_listed_date_combined").text());
|
6287
|
-
list.push({
|
6288
|
-
listingid,
|
6289
|
-
appid,
|
6290
|
-
contextid,
|
6291
|
-
itemid,
|
6292
|
-
buyer_pays_price,
|
6293
|
-
receive_price,
|
6294
|
-
item_name,
|
6295
|
-
game_name,
|
6296
|
-
date_combined,
|
6297
|
-
image,
|
6298
|
-
});
|
6299
|
-
} catch (e) {}
|
6300
|
-
});
|
6301
|
-
const assets = Object.values(data.assets["730"]?.["2"] || {});
|
6302
|
-
return { list, assets, success: true };
|
6270
|
+
if (data?.success !== true) {
|
6271
|
+
return null;
|
6303
6272
|
}
|
6273
|
+
|
6274
|
+
const $ = cheerio.load(data.results_html);
|
6275
|
+
const list = [];
|
6276
|
+
$(".market_listing_row").each(function () {
|
6277
|
+
try {
|
6278
|
+
const $row = $(this);
|
6279
|
+
const [sElementPrefix, listingid, appid, contextid, itemid] = $row
|
6280
|
+
.find(".market_listing_cancel_button > a")
|
6281
|
+
.attr("href")
|
6282
|
+
.split("(")[1]
|
6283
|
+
.split(")")[0]
|
6284
|
+
.split(",")
|
6285
|
+
.map((r) => r.trim().replaceAll(`'`, "").replaceAll(`"`, ""));
|
6286
|
+
const image = $row.find(`#mylisting_${listingid}_image`).attr("src");
|
6287
|
+
const buyer_pays_price = StringUtils.cleanSpace($row.find(`.market_listing_price span[title="This is the price the buyer pays."]`).text().replaceAll(`(`, "").replaceAll(`)`, ""));
|
6288
|
+
const receive_price = StringUtils.cleanSpace($row.find(`.market_listing_price span[title="This is how much you will receive."]`).text().replaceAll(`(`, "").replaceAll(`)`, ""));
|
6289
|
+
const item_name = $row.find(".market_listing_item_name_link").text() || $row.find(".market_listing_item_name").text();
|
6290
|
+
const game_name = $row.find(".market_listing_game_name").text();
|
6291
|
+
const date_combined = formatMarketHistoryDate(StringUtils.cleanSpace($row.find(".market_listing_game_name + .market_listing_listed_date_combined").text()));
|
6292
|
+
list.push({
|
6293
|
+
listingid,
|
6294
|
+
appid,
|
6295
|
+
contextid,
|
6296
|
+
itemid,
|
6297
|
+
buyer_pays_price,
|
6298
|
+
receive_price,
|
6299
|
+
item_name,
|
6300
|
+
game_name,
|
6301
|
+
date_combined,
|
6302
|
+
image,
|
6303
|
+
});
|
6304
|
+
} catch (e) {}
|
6305
|
+
});
|
6306
|
+
const assets = Object.values(data.assets["730"]?.["2"] || {});
|
6307
|
+
return { list, assets, success: true };
|
6304
6308
|
}
|
6305
6309
|
|
6306
6310
|
async getMyMarketHistory({ start = 0, count = 100 } = {}) {
|
6307
6311
|
const result = await this._httpRequestAjax({
|
6308
6312
|
url: `market/myhistory/render/?query=&start=${start}&count=${count}`,
|
6309
6313
|
});
|
6314
|
+
|
6310
6315
|
if (result instanceof ResponseError) {
|
6311
6316
|
return result;
|
6312
6317
|
}
|
6318
|
+
|
6313
6319
|
const data = result?.data;
|
6314
|
-
if (data?.success
|
6315
|
-
|
6316
|
-
|
6317
|
-
|
6318
|
-
|
6319
|
-
|
6320
|
-
|
6321
|
-
|
6322
|
-
|
6323
|
-
|
6324
|
-
|
6325
|
-
|
6326
|
-
|
6320
|
+
if (data?.success !== true) {
|
6321
|
+
return null;
|
6322
|
+
}
|
6323
|
+
|
6324
|
+
const hovers = StringUtils.cleanSpace(data.hovers);
|
6325
|
+
const assetById = data.assets?.[730]?.[2] || {};
|
6326
|
+
const assestByListingId = {};
|
6327
|
+
hovers.split("CreateItemHoverFromContainer").forEach(function (text) {
|
6328
|
+
text = text.trim();
|
6329
|
+
if (!text.startsWith("(")) {
|
6330
|
+
return;
|
6331
|
+
}
|
6332
|
+
const texts = text.split(",");
|
6333
|
+
const listingId = texts[1]?.substringBetweenOrNull("history_row_", "_");
|
6334
|
+
const assestId = texts[4]?.trim()?.removeSurrounding("'");
|
6335
|
+
if (!listingId || !assestId || !assetById[assestId]) {
|
6336
|
+
return;
|
6337
|
+
}
|
6338
|
+
assestByListingId[listingId] = assestId;
|
6339
|
+
});
|
6340
|
+
|
6341
|
+
const $ = cheerio.load(data.results_html);
|
6342
|
+
const list = [...$(".market_listing_row")]
|
6343
|
+
.map(function (el) {
|
6344
|
+
el = $(el);
|
6345
|
+
const id = el.attr("id");
|
6346
|
+
const listingid = id.substringBetweenOrNull("history_row_", "_");
|
6347
|
+
if (!listingid) {
|
6327
6348
|
return;
|
6328
6349
|
}
|
6329
|
-
|
6330
|
-
|
6331
|
-
|
6332
|
-
|
6333
|
-
|
6334
|
-
.
|
6335
|
-
|
6336
|
-
|
6337
|
-
const listingid = id.substringBetweenOrNull("history_row_", "_");
|
6338
|
-
if (!listingid) {
|
6339
|
-
return;
|
6340
|
-
}
|
6341
|
-
const gainOrLoss = StringUtils.cleanSpace(el.find(".market_listing_gainorloss").text());
|
6342
|
-
const image = el.find(`.market_listing_item_img`).attr("src");
|
6343
|
-
const price = parseInt(el.find(`.market_table_value .market_listing_price`).text().replaceAll(`(`, "").replaceAll(`)`, "").replaceAll(`₫`, "").replaceAll(`.`, "").replaceAll(`,`, "").trim()) || "";
|
6344
|
-
const item_name = el.find(".market_listing_item_name").text();
|
6345
|
-
const game_name = el.find(".market_listing_game_name").text();
|
6346
|
-
const listedOn = StringUtils.cleanSpace(el.find(".market_listing_listed_date + .market_listing_listed_date").text().replaceAll(`Listed:`, ""));
|
6347
|
-
const actedOn = StringUtils.cleanSpace(el.find(".market_listing_whoactedwith + .market_listing_listed_date").text().replaceAll(`Listed:`, ""));
|
6348
|
-
const status = StringUtils.cleanSpace(el.find(".market_listing_whoactedwith").text());
|
6350
|
+
const gainOrLoss = StringUtils.cleanSpace(el.find(".market_listing_gainorloss").text());
|
6351
|
+
const image = el.find(`.market_listing_item_img`).attr("src");
|
6352
|
+
const price = parseInt(el.find(`.market_table_value .market_listing_price`).text().replaceAll(`(`, "").replaceAll(`)`, "").replaceAll(`₫`, "").replaceAll(`.`, "").replaceAll(`,`, "").trim()) || "";
|
6353
|
+
const item_name = el.find(".market_listing_item_name").text();
|
6354
|
+
const game_name = el.find(".market_listing_game_name").text();
|
6355
|
+
const listedOn = formatMarketHistoryDate(StringUtils.cleanSpace(el.find(".market_listing_listed_date + .market_listing_listed_date").text().replaceAll(`Listed:`, "")));
|
6356
|
+
const actedOn = formatMarketHistoryDate(StringUtils.cleanSpace(el.find(".market_listing_whoactedwith + .market_listing_listed_date").text().replaceAll(`Listed:`, "")));
|
6357
|
+
const status = StringUtils.cleanSpace(el.find(".market_listing_whoactedwith").text());
|
6349
6358
|
|
6350
|
-
|
6351
|
-
|
6352
|
-
|
6353
|
-
|
6354
|
-
|
6355
|
-
|
6356
|
-
|
6357
|
-
|
6358
|
-
|
6359
|
-
|
6360
|
-
|
6361
|
-
|
6362
|
-
|
6363
|
-
|
6364
|
-
|
6365
|
-
|
6366
|
-
|
6367
|
-
}
|
6359
|
+
return {
|
6360
|
+
id,
|
6361
|
+
listingid,
|
6362
|
+
price,
|
6363
|
+
item_name,
|
6364
|
+
game_name,
|
6365
|
+
listedOn,
|
6366
|
+
actedOn,
|
6367
|
+
image,
|
6368
|
+
gainOrLoss,
|
6369
|
+
status,
|
6370
|
+
...(!!assestByListingId[listingid] && { assetId: assestByListingId[listingid] }),
|
6371
|
+
};
|
6372
|
+
})
|
6373
|
+
.filter(Boolean);
|
6374
|
+
const assets = Object.values(assetById);
|
6375
|
+
return { ...data, list, assets, success: true };
|
6368
6376
|
}
|
6369
6377
|
|
6370
6378
|
async getPlayerReports(token) {
|
@@ -7257,8 +7265,8 @@ export default class SteamUser {
|
|
7257
7265
|
}
|
7258
7266
|
|
7259
7267
|
data.communityitemid = Number(data.communityitemid);
|
7260
|
-
if(!data.communityitemid){
|
7261
|
-
return
|
7268
|
+
if (!data.communityitemid) {
|
7269
|
+
return;
|
7262
7270
|
}
|
7263
7271
|
return data;
|
7264
7272
|
}
|