mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2026-08-19 13:13:28 +08:00
Formatting
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
const Cheerio = require("cheerio");
|
const Cheerio = require('cheerio');
|
||||||
const SteamID = require("steamid");
|
const SteamID = require('steamid');
|
||||||
const Helpers = require('../components/helpers.js');
|
const Helpers = require('../components/helpers.js');
|
||||||
const SteamCommunity = require("../index.js");
|
const SteamCommunity = require('../index.js');
|
||||||
const SteamIdResolver = require("steamid-resolver");
|
const SteamIdResolver = require('steamid-resolver');
|
||||||
const ESharedfileType = require("../resources/ESharedfileType.js");
|
const ESharedfileType = require('../resources/ESharedfileType.js');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,126 +12,148 @@ const ESharedfileType = require("../resources/ESharedfileType.js");
|
|||||||
* @param {function} callback - First argument is null/Error, second is object containing all available information
|
* @param {function} callback - First argument is null/Error, second is object containing all available information
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.getSteamSharedfile = function(sid, callback) {
|
SteamCommunity.prototype.getSteamSharedfile = function(sid, callback) {
|
||||||
// Construct object holding all the data we can scrape
|
|
||||||
let sharedfile = {
|
// Construct object holding all the data we can scrape
|
||||||
id: sid,
|
let sharedfile = {
|
||||||
type: null,
|
id: sid,
|
||||||
appID: null,
|
type: null,
|
||||||
owner: null,
|
appID: null,
|
||||||
fileSize: null,
|
owner: null,
|
||||||
postDate: null,
|
fileSize: null,
|
||||||
resolution: null,
|
postDate: null,
|
||||||
uniqueVisitorsCount: null,
|
resolution: null,
|
||||||
favoritesCount: null,
|
uniqueVisitorsCount: null,
|
||||||
upvoteCount: null
|
favoritesCount: null,
|
||||||
}
|
upvoteCount: null
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Get DOM of sharedfile
|
// Get DOM of sharedfile
|
||||||
this.httpRequestGet(`https://steamcommunity.com/sharedfiles/filedetails/?id=${sid}`, (err, res, body) => {
|
this.httpRequestGet(`https://steamcommunity.com/sharedfiles/filedetails/?id=${sid}`, (err, res, body) => {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
/* --------------------- Preprocess output --------------------- */
|
/* --------------------- Preprocess output --------------------- */
|
||||||
|
|
||||||
// Load output into cheerio to make parsing easier
|
// Load output into cheerio to make parsing easier
|
||||||
let $ = Cheerio.load(body);
|
let $ = Cheerio.load(body);
|
||||||
|
|
||||||
// Dynamically map detailsStatsContainerLeft to detailsStatsContainerRight in an object to make readout easier. It holds size, post date and resolution.
|
// Dynamically map detailsStatsContainerLeft to detailsStatsContainerRight in an object to make readout easier. It holds size, post date and resolution.
|
||||||
let detailsStatsObj = {};
|
let detailsStatsObj = {};
|
||||||
let detailsLeft = $(".detailsStatsContainerLeft").children();
|
let detailsLeft = $(".detailsStatsContainerLeft").children();
|
||||||
let detailsRight = $(".detailsStatsContainerRight").children();
|
let detailsRight = $(".detailsStatsContainerRight").children();
|
||||||
|
|
||||||
Object.keys(detailsLeft).forEach((e) => { // Dynamically get all details. Don't hardcore so that this also works for guides.
|
Object.keys(detailsLeft).forEach((e) => { // Dynamically get all details. Don't hardcore so that this also works for guides.
|
||||||
if (isNaN(e)) return; // Ignore invalid entries
|
if (isNaN(e)) {
|
||||||
|
return; // Ignore invalid entries
|
||||||
|
}
|
||||||
|
|
||||||
detailsStatsObj[detailsLeft[e].children[0].data.trim()] = detailsRight[e].children[0].data;
|
detailsStatsObj[detailsLeft[e].children[0].data.trim()] = detailsRight[e].children[0].data;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Dynamically map stats_table descriptions to values. This holds Unique Visitors and Current Favorites
|
// Dynamically map stats_table descriptions to values. This holds Unique Visitors and Current Favorites
|
||||||
let statsTableObj = {};
|
let statsTableObj = {};
|
||||||
let statsTable = $(".stats_table").children();
|
let statsTable = $(".stats_table").children();
|
||||||
|
|
||||||
Object.keys(statsTable).forEach((e, i) => {
|
Object.keys(statsTable).forEach((e) => {
|
||||||
if (isNaN(e)) return; // Ignore invalid entries
|
if (isNaN(e)) {
|
||||||
|
return; // Ignore invalid entries
|
||||||
|
}
|
||||||
|
|
||||||
// Value description is at index 3, value data at index 1
|
// Value description is at index 3, value data at index 1
|
||||||
statsTableObj[statsTable[e].children[3].children[0].data] = statsTable[e].children[1].children[0].data.replace(/,/g, ""); // Remove commas from 1k+ values
|
statsTableObj[statsTable[e].children[3].children[0].data] = statsTable[e].children[1].children[0].data.replace(/,/g, ""); // Remove commas from 1k+ values
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* --------------------- Find and map values --------------------- */
|
/* --------------------- Find and map values --------------------- */
|
||||||
|
|
||||||
// Find appID in share button onclick event
|
// Find appID in share button onclick event
|
||||||
sharedfile.appID = Number($("#ShareItemBtn").attr()["onclick"].replace(`ShowSharePublishedFilePopup( '${sid}', '`, "").replace("' );", ""))
|
sharedfile.appID = Number($("#ShareItemBtn").attr()["onclick"].replace(`ShowSharePublishedFilePopup( '${sid}', '`, "").replace("' );", ""));
|
||||||
|
|
||||||
|
|
||||||
// Find fileSize if not guide
|
// Find fileSize if not guide
|
||||||
sharedfile.fileSize = detailsStatsObj["File Size"] || null; // TODO: Convert to bytes? It seems like to always be MB but no guarantee
|
sharedfile.fileSize = detailsStatsObj["File Size"] || null; // TODO: Convert to bytes? It seems like to always be MB but no guarantee
|
||||||
|
|
||||||
|
|
||||||
// Find postDate and convert to timestamp
|
// Find postDate and convert to timestamp
|
||||||
let posted = detailsStatsObj["Posted"].trim();
|
let posted = detailsStatsObj["Posted"].trim();
|
||||||
|
|
||||||
sharedfile.postDate = Date.parse(Helpers.decodeSteamTime(posted)); // Pass String into helper and parse the returned String to get a Unix timestamp
|
sharedfile.postDate = Date.parse(Helpers.decodeSteamTime(posted)); // Pass String into helper and parse the returned String to get a Unix timestamp
|
||||||
|
|
||||||
|
|
||||||
// Find resolution if artwork or screenshot
|
// Find resolution if artwork or screenshot
|
||||||
sharedfile.resolution = detailsStatsObj["Size"] || null;
|
sharedfile.resolution = detailsStatsObj["Size"] || null;
|
||||||
|
|
||||||
|
|
||||||
// Find uniqueVisitorsCount. We can't use ' || null' here as Number("0") casts to false
|
// Find uniqueVisitorsCount. We can't use ' || null' here as Number("0") casts to false
|
||||||
if (statsTableObj["Unique Visitors"]) sharedfile.uniqueVisitorsCount = Number(statsTableObj["Unique Visitors"]);
|
if (statsTableObj["Unique Visitors"]) {
|
||||||
|
sharedfile.uniqueVisitorsCount = Number(statsTableObj["Unique Visitors"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Find favoritesCount. We can't use ' || null' here as Number("0") casts to false
|
// Find favoritesCount. We can't use ' || null' here as Number("0") casts to false
|
||||||
if (statsTableObj["Current Favorites"]) sharedfile.favoritesCount = Number(statsTableObj["Current Favorites"]);
|
if (statsTableObj["Current Favorites"]) {
|
||||||
|
sharedfile.favoritesCount = Number(statsTableObj["Current Favorites"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Find upvoteCount. We can't use ' || null' here as Number("0") casts to false
|
// Find upvoteCount. We can't use ' || null' here as Number("0") casts to false
|
||||||
let upvoteCount = $("#VotesUpCountContainer > #VotesUpCount").text();
|
let upvoteCount = $("#VotesUpCountContainer > #VotesUpCount").text();
|
||||||
if (upvoteCount) sharedfile.upvoteCount = Number(upvoteCount);
|
|
||||||
|
if (upvoteCount) {
|
||||||
|
sharedfile.upvoteCount = Number(upvoteCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Determine type by looking at the second breadcrumb. Find the first separator as it has a unique name and go to the next element which holds our value of interest
|
// Determine type by looking at the second breadcrumb. Find the first separator as it has a unique name and go to the next element which holds our value of interest
|
||||||
let breadcrumb = $(".breadcrumbs > .breadcrumb_separator").next().get(0).children[0].data || "";
|
let breadcrumb = $(".breadcrumbs > .breadcrumb_separator").next().get(0).children[0].data || "";
|
||||||
|
|
||||||
if (breadcrumb.includes("Screenshot")) sharedfile.type = ESharedfileType.Screenshot;
|
if (breadcrumb.includes("Screenshot")) {
|
||||||
if (breadcrumb.includes("Artwork")) sharedfile.type = ESharedfileType.Artwork;
|
sharedfile.type = ESharedfileType.Screenshot;
|
||||||
if (breadcrumb.includes("Guide")) sharedfile.type = ESharedfileType.Guide;
|
}
|
||||||
|
|
||||||
|
if (breadcrumb.includes("Artwork")) {
|
||||||
|
sharedfile.type = ESharedfileType.Artwork;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (breadcrumb.includes("Guide")) {
|
||||||
|
sharedfile.type = ESharedfileType.Guide;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Find owner profile link, convert to steamID64 using SteamIdResolver lib and create a SteamID object
|
// Find owner profile link, convert to steamID64 using SteamIdResolver lib and create a SteamID object
|
||||||
let ownerHref = $(".friendBlockLinkOverlay").attr()["href"];
|
let ownerHref = $(".friendBlockLinkOverlay").attr()["href"];
|
||||||
|
|
||||||
SteamIdResolver.customUrlToSteamID64(ownerHref, (err, steamID64) => { // This request takes <1 sec
|
SteamIdResolver.customUrlToSteamID64(ownerHref, (err, steamID64) => { // This request takes <1 sec
|
||||||
if (!err) sharedfile.owner = new SteamID(steamID64);
|
if (!err) {
|
||||||
|
sharedfile.owner = new SteamID(steamID64);
|
||||||
|
}
|
||||||
|
|
||||||
// Make callback when ID was resolved as otherwise owner will always be null
|
// Make callback when ID was resolved as otherwise owner will always be null
|
||||||
callback(null, new CSteamSharedfile(this, sharedfile));
|
callback(null, new CSteamSharedfile(this, sharedfile));
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
}
|
}
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
function CSteamSharedfile(community, data) {
|
function CSteamSharedfile(community, data) {
|
||||||
this._community = community;
|
this._community = community;
|
||||||
|
|
||||||
// Clone all the data we recieved
|
// Clone all the data we recieved
|
||||||
Object.assign(this, data); // TODO: This is cleaner but might break IntelliSense
|
Object.assign(this, data); // TODO: This is cleaner but might break IntelliSense. I'm leaving the block below to be reactivated if necessary
|
||||||
|
|
||||||
/* this.id = data.id;
|
/* this.id = data.id;
|
||||||
this.type = data.type;
|
this.type = data.type;
|
||||||
this.appID = data.appID;
|
this.appID = data.appID;
|
||||||
this.owner = data.owner;
|
this.owner = data.owner;
|
||||||
this.fileSize = data.fileSize;
|
this.fileSize = data.fileSize;
|
||||||
this.postDate = data.postDate;
|
this.postDate = data.postDate;
|
||||||
this.resolution = data.resolution;
|
this.resolution = data.resolution;
|
||||||
this.uniqueVisitorsCount = data.uniqueVisitorsCount;
|
this.uniqueVisitorsCount = data.uniqueVisitorsCount;
|
||||||
this.favoritesCount = data.favoritesCount;
|
this.favoritesCount = data.favoritesCount;
|
||||||
this.upvoteCount = data.upvoteCount; */
|
this.upvoteCount = data.upvoteCount; */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,7 +162,7 @@ function CSteamSharedfile(community, data) {
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
CSteamSharedfile.prototype.deleteComment = function(cid, callback) {
|
CSteamSharedfile.prototype.deleteComment = function(cid, callback) {
|
||||||
this._community.deleteSharedfileComment(this.userID, this.id, cid, callback);
|
this._community.deleteSharedfileComment(this.userID, this.id, cid, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,7 +170,7 @@ CSteamSharedfile.prototype.deleteComment = function(cid, callback) {
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
CSteamSharedfile.prototype.favorite = function(callback) {
|
CSteamSharedfile.prototype.favorite = function(callback) {
|
||||||
this._community.favoriteSharedfile(this.id, this.appID, callback);
|
this._community.favoriteSharedfile(this.id, this.appID, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,7 +179,7 @@ CSteamSharedfile.prototype.favorite = function(callback) {
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
CSteamSharedfile.prototype.comment = function(message, callback) {
|
CSteamSharedfile.prototype.comment = function(message, callback) {
|
||||||
this._community.postSharedfileComment(this.owner, this.id, message, callback);
|
this._community.postSharedfileComment(this.owner, this.id, message, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -165,7 +187,7 @@ CSteamSharedfile.prototype.comment = function(message, callback) {
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
CSteamSharedfile.prototype.subscribe = function(callback) {
|
CSteamSharedfile.prototype.subscribe = function(callback) {
|
||||||
this._community.subscribeSharedfileComments(this.owner, this.id, callback);
|
this._community.subscribeSharedfileComments(this.owner, this.id, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,7 +195,7 @@ CSteamSharedfile.prototype.subscribe = function(callback) {
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
CSteamSharedfile.prototype.unfavorite = function(callback) {
|
CSteamSharedfile.prototype.unfavorite = function(callback) {
|
||||||
this._community.unfavoriteSharedfile(this.id, this.appID, callback);
|
this._community.unfavoriteSharedfile(this.id, this.appID, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,7 +203,7 @@ CSteamSharedfile.prototype.unfavorite = function(callback) {
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
CSteamSharedfile.prototype.unsubscribe = function(callback) {
|
CSteamSharedfile.prototype.unsubscribe = function(callback) {
|
||||||
this._community.unsubscribeSharedfileComments(this.owner, this.id, callback);
|
this._community.unsubscribeSharedfileComments(this.owner, this.id, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -189,7 +211,7 @@ CSteamSharedfile.prototype.unsubscribe = function(callback) {
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
CSteamSharedfile.prototype.voteDown = function(callback) {
|
CSteamSharedfile.prototype.voteDown = function(callback) {
|
||||||
this._community.voteDownSharedfile(this.id, callback);
|
this._community.voteDownSharedfile(this.id, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,5 +219,5 @@ CSteamSharedfile.prototype.voteDown = function(callback) {
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
CSteamSharedfile.prototype.voteUp = function(callback) {
|
CSteamSharedfile.prototype.voteUp = function(callback) {
|
||||||
this._community.voteUpSharedfile(this.id, callback);
|
this._community.voteUpSharedfile(this.id, callback);
|
||||||
};
|
};
|
||||||
@@ -10,24 +10,24 @@ var SteamID = require('steamid');
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.deleteSharedfileComment = function(userID, sid, cid, callback) {
|
SteamCommunity.prototype.deleteSharedfileComment = function(userID, sid, cid, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID === "string") {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/delete/${userID.toString()}/${sid}/`,
|
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/delete/${userID.toString()}/${sid}/`,
|
||||||
"form": {
|
"form": {
|
||||||
"gidcomment": cid,
|
"gidcomment": cid,
|
||||||
"count": 10,
|
"count": 10,
|
||||||
"sessionid": this.getSessionID()
|
"sessionid": this.getSessionID()
|
||||||
}
|
}
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(null || err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,20 +37,20 @@ SteamCommunity.prototype.deleteSharedfileComment = function(userID, sid, cid, ca
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.favoriteSharedfile = function(sid, appid, callback) {
|
SteamCommunity.prototype.favoriteSharedfile = function(sid, appid, callback) {
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/sharedfiles/favorite",
|
"uri": "https://steamcommunity.com/sharedfiles/favorite",
|
||||||
"form": {
|
"form": {
|
||||||
"id": sid,
|
"id": sid,
|
||||||
"appid": appid,
|
"appid": appid,
|
||||||
"sessionid": this.getSessionID()
|
"sessionid": this.getSessionID()
|
||||||
}
|
}
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(null || err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,24 +61,24 @@ SteamCommunity.prototype.favoriteSharedfile = function(sid, appid, callback) {
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.postSharedfileComment = function(userID, sid, message, callback) {
|
SteamCommunity.prototype.postSharedfileComment = function(userID, sid, message, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID === "string") {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/post/${userID.toString()}/${sid}/`,
|
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/post/${userID.toString()}/${sid}/`,
|
||||||
"form": {
|
"form": {
|
||||||
"comment": message,
|
"comment": message,
|
||||||
"count": 10,
|
"count": 10,
|
||||||
"sessionid": this.getSessionID()
|
"sessionid": this.getSessionID()
|
||||||
}
|
}
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(null || err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,23 +88,23 @@ SteamCommunity.prototype.postSharedfileComment = function(userID, sid, message,
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.subscribeSharedfileComments = function(userID, sid, callback) {
|
SteamCommunity.prototype.subscribeSharedfileComments = function(userID, sid, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID === "string") {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/subscribe/${userID.toString()}/${sid}/`,
|
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/subscribe/${userID.toString()}/${sid}/`,
|
||||||
"form": {
|
"form": {
|
||||||
"count": 10,
|
"count": 10,
|
||||||
"sessionid": this.getSessionID()
|
"sessionid": this.getSessionID()
|
||||||
}
|
}
|
||||||
}, function(err, response, body) { // eslint-disable-line
|
}, function(err, response, body) { // eslint-disable-line
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(null || err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,20 +114,20 @@ SteamCommunity.prototype.subscribeSharedfileComments = function(userID, sid, cal
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.unfavoriteSharedfile = function(sid, appid, callback) {
|
SteamCommunity.prototype.unfavoriteSharedfile = function(sid, appid, callback) {
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/sharedfiles/unfavorite",
|
"uri": "https://steamcommunity.com/sharedfiles/unfavorite",
|
||||||
"form": {
|
"form": {
|
||||||
"id": sid,
|
"id": sid,
|
||||||
"appid": appid,
|
"appid": appid,
|
||||||
"sessionid": this.getSessionID()
|
"sessionid": this.getSessionID()
|
||||||
}
|
}
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(null || err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,23 +137,23 @@ SteamCommunity.prototype.unfavoriteSharedfile = function(sid, appid, callback) {
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.unsubscribeSharedfileComments = function(userID, sid, callback) {
|
SteamCommunity.prototype.unsubscribeSharedfileComments = function(userID, sid, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID === "string") {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/unsubscribe/${userID.toString()}/${sid}/`,
|
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/unsubscribe/${userID.toString()}/${sid}/`,
|
||||||
"form": {
|
"form": {
|
||||||
"count": 10,
|
"count": 10,
|
||||||
"sessionid": this.getSessionID()
|
"sessionid": this.getSessionID()
|
||||||
}
|
}
|
||||||
}, function(err, response, body) { // eslint-disable-line
|
}, function(err, response, body) { // eslint-disable-line
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(null || err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,19 +162,19 @@ SteamCommunity.prototype.unsubscribeSharedfileComments = function(userID, sid, c
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.voteDownSharedfile = function(sid, callback) {
|
SteamCommunity.prototype.voteDownSharedfile = function(sid, callback) {
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/sharedfiles/votedown",
|
"uri": "https://steamcommunity.com/sharedfiles/votedown",
|
||||||
"form": {
|
"form": {
|
||||||
"id": sid,
|
"id": sid,
|
||||||
"sessionid": this.getSessionID()
|
"sessionid": this.getSessionID()
|
||||||
}
|
}
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(null || err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,17 +183,17 @@ SteamCommunity.prototype.voteDownSharedfile = function(sid, callback) {
|
|||||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.voteUpSharedfile = function(sid, callback) {
|
SteamCommunity.prototype.voteUpSharedfile = function(sid, callback) {
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/sharedfiles/voteup",
|
"uri": "https://steamcommunity.com/sharedfiles/voteup",
|
||||||
"form": {
|
"form": {
|
||||||
"id": sid,
|
"id": sid,
|
||||||
"sessionid": this.getSessionID()
|
"sessionid": this.getSessionID()
|
||||||
}
|
}
|
||||||
}, function(err, response, body) {
|
}, function(err, response, body) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(null || err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
* @enum ESharedfileType
|
* @enum ESharedfileType
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"Screenshot": 0,
|
"Screenshot": 0,
|
||||||
"Artwork": 1,
|
"Artwork": 1,
|
||||||
"Guide": 2,
|
"Guide": 2,
|
||||||
|
|
||||||
// Value-to-name mapping for convenience
|
// Value-to-name mapping for convenience
|
||||||
"0": "Screenshot",
|
"0": "Screenshot",
|
||||||
"1": "Artwork",
|
"1": "Artwork",
|
||||||
"2": "Guide"
|
"2": "Guide"
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user