steamutils 1.5.18 → 1.5.19
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 +63 -74
- package/package.json +1 -1
package/index.js
CHANGED
@@ -3966,98 +3966,87 @@ export default class SteamUser {
|
|
3966
3966
|
}
|
3967
3967
|
|
3968
3968
|
async getFriendActivity(params) {
|
3969
|
-
let
|
3970
|
-
|
3971
|
-
|
3972
|
-
|
3973
|
-
|
3974
|
-
url = params;
|
3975
|
-
} else {
|
3976
|
-
start = params;
|
3977
|
-
}
|
3969
|
+
let start,
|
3970
|
+
url,
|
3971
|
+
filter = {};
|
3972
|
+
if (typeof params === "string") {
|
3973
|
+
params.startsWith("http") ? (url = params) : (start = params);
|
3978
3974
|
} else if (typeof params === "number") {
|
3979
3975
|
start = params;
|
3980
|
-
} else if (typeof params === "object") {
|
3981
|
-
|
3976
|
+
} else if (params && typeof params === "object") {
|
3977
|
+
({ start, url, filter = {} } = params);
|
3982
3978
|
}
|
3983
3979
|
|
3984
|
-
|
3980
|
+
start = start || Math.floor(Date.now() / 1000);
|
3985
3981
|
url = url || `${this.getMyProfileURL()}/ajaxgetusernews/?start=${start}`; //use my, not profiles/76561197977736539 getMySteamUserProfileURL
|
3982
|
+
|
3986
3983
|
const _self = this;
|
3987
3984
|
const activity = [];
|
3988
|
-
let next_request_timestart = null;
|
3989
|
-
let next_request = null;
|
3990
3985
|
const result = await this._httpRequestAjax(url);
|
3991
3986
|
if (result instanceof ResponseError) {
|
3992
3987
|
return result;
|
3993
3988
|
}
|
3994
3989
|
const data = result?.data;
|
3995
|
-
if (data?.success) {
|
3996
|
-
|
3997
|
-
|
3998
|
-
|
3999
|
-
|
4000
|
-
|
4001
|
-
|
4002
|
-
|
4003
|
-
|
4004
|
-
|
4005
|
-
|
4006
|
-
|
4007
|
-
|
4008
|
-
|
4009
|
-
|
4010
|
-
|
4011
|
-
|
4012
|
-
|
4013
|
-
|
4014
|
-
|
4015
|
-
userstatus() {},
|
4016
|
-
screenshot() {
|
4017
|
-
//screenshot_fullscreen
|
4018
|
-
},
|
4019
|
-
videopublished() {},
|
4020
|
-
};
|
3990
|
+
if (!data?.success) return { activity, next_request_timestart: null, next_request: null };
|
3991
|
+
|
3992
|
+
const next_request = data.next_request || "";
|
3993
|
+
const next_request_timestart = parseInt(next_request.substringAfterLast("?start=")) || null;
|
3994
|
+
const $ = cheerio.load(data.blotter_html.replaceAll(/[\t\n\r]/gi, "").trim());
|
3995
|
+
const activityTypeHandlers = {
|
3996
|
+
daily_rollup(blotterBlockEl) {
|
3997
|
+
return _self._parseBlotterDailyRollup($, blotterBlockEl);
|
3998
|
+
},
|
3999
|
+
gamepurchase(blotterBlockEl) {
|
4000
|
+
return _self._parseBlotterGamepurchase($, blotterBlockEl);
|
4001
|
+
},
|
4002
|
+
workshopitempublished() {},
|
4003
|
+
recommendation() {},
|
4004
|
+
userstatus() {},
|
4005
|
+
screenshot() {
|
4006
|
+
//screenshot_fullscreen
|
4007
|
+
},
|
4008
|
+
videopublished() {},
|
4009
|
+
};
|
4021
4010
|
|
4022
|
-
|
4023
|
-
|
4024
|
-
|
4025
|
-
|
4026
|
-
|
4027
|
-
|
4028
|
-
|
4029
|
-
|
4030
|
-
|
4011
|
+
$(".blotter_day").each(function (_, dayElement) {
|
4012
|
+
const dayEl = $(dayElement);
|
4013
|
+
const timestamp = parseInt(dayEl.attr("id").substringAfter("blotter_day_"));
|
4014
|
+
const header_date = dayEl.find(".blotter_day_header_date").text();
|
4015
|
+
|
4016
|
+
dayEl.find(".blotter_block").each(function (index, blotterBlockEl) {
|
4017
|
+
blotterBlockEl = $(blotterBlockEl);
|
4018
|
+
const types = Array.from(
|
4019
|
+
new Set(
|
4020
|
+
blotterBlockEl
|
4021
|
+
.children()
|
4022
|
+
.map((_, child) => $(child).attr("class")?.replace("blotter_entry", "").trim())
|
4023
|
+
.get()
|
4024
|
+
.flatMap((cls) => cls?.split(" ").map((c) => c.replace("blotter_", "")) || []),
|
4025
|
+
),
|
4026
|
+
);
|
4031
4027
|
|
4032
|
-
|
4033
|
-
|
4034
|
-
|
4035
|
-
|
4036
|
-
|
4037
|
-
|
4038
|
-
___activity.type = excute;
|
4039
|
-
}
|
4028
|
+
const handlerKey = types.find((type) => activityTypeHandlers[type]);
|
4029
|
+
if (!handlerKey) {
|
4030
|
+
const html = blotterBlockEl.html();
|
4031
|
+
console.log(html);
|
4032
|
+
return;
|
4033
|
+
}
|
4040
4034
|
|
4041
|
-
|
4042
|
-
|
4043
|
-
|
4044
|
-
|
4045
|
-
|
4046
|
-
|
4047
|
-
console.log(html);
|
4048
|
-
}
|
4049
|
-
});
|
4050
|
-
_activity.forEach((ac) => {
|
4051
|
-
ac.timestamp = timestamp;
|
4052
|
-
ac.header_date = header_date;
|
4035
|
+
const parsedActivities = activityTypeHandlers[handlerKey](blotterBlockEl) || [];
|
4036
|
+
if (Array.isArray([parsedActivities])) {
|
4037
|
+
for (const parsedActivity of parsedActivities) {
|
4038
|
+
parsedActivity.type ||= handlerKey;
|
4039
|
+
parsedActivity.timestamp = timestamp;
|
4040
|
+
parsedActivity.header_date = header_date;
|
4053
4041
|
|
4054
|
-
|
4055
|
-
|
4042
|
+
if (filter?.type && filter.type !== parsedActivity.type) {
|
4043
|
+
continue;
|
4044
|
+
}
|
4045
|
+
activity.push(parsedActivity);
|
4056
4046
|
}
|
4057
|
-
|
4058
|
-
});
|
4047
|
+
}
|
4059
4048
|
});
|
4060
|
-
}
|
4049
|
+
});
|
4061
4050
|
|
4062
4051
|
return {
|
4063
4052
|
activity,
|