mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2024-12-26 06:40:09 +08:00
Some minor updates
This commit is contained in:
parent
4ca0fc83aa
commit
36e8c79d87
@ -2,8 +2,8 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/../node-steamcommunity Wiki/.idea/node-steamcommunity Wiki.iml" filepath="$PROJECT_DIR$/../node-steamcommunity Wiki/.idea/node-steamcommunity Wiki.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/steamcommunity.iml" filepath="$PROJECT_DIR$/.idea/steamcommunity.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/steamcommunity.iml" filepath="$PROJECT_DIR$/.idea/steamcommunity.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/../steamcommunity Wiki/.idea/steamcommunity Wiki.iml" filepath="$PROJECT_DIR$/../steamcommunity Wiki/.idea/steamcommunity Wiki.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="module" module-name="node-steamcommunity Wiki" />
|
<orderEntry type="module" module-name="steamcommunity Wiki" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$/../node-steamcommunity Wiki" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$/../steamcommunity Wiki" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -1,17 +1,18 @@
|
|||||||
const Cheerio = require('cheerio');
|
const Cheerio = require('cheerio');
|
||||||
const SteamID = require('steamid');
|
const SteamID = require('steamid');
|
||||||
const Helpers = require('../components/helpers.js');
|
|
||||||
const SteamCommunity = require('../index.js');
|
const SteamCommunity = require('../index.js');
|
||||||
const ESharedfileType = require('../resources/ESharedfileType.js');
|
const Helpers = require('../components/helpers.js');
|
||||||
|
|
||||||
|
const ESharedFileType = require('../resources/ESharedFileType.js');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrape a sharedfile's DOM to get all available information
|
* Scrape a sharedfile's DOM to get all available information
|
||||||
* @param {String} sharedFileId - ID of the sharedfile
|
* @param {string} sharedFileId - ID of the sharedfile
|
||||||
* @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(sharedFileId, callback) {
|
SteamCommunity.prototype.getSteamSharedFile = function(sharedFileId, callback) {
|
||||||
|
|
||||||
// Construct object holding all the data we can scrape
|
// Construct object holding all the data we can scrape
|
||||||
let sharedfile = {
|
let sharedfile = {
|
||||||
id: sharedFileId,
|
id: sharedFileId,
|
||||||
@ -29,7 +30,6 @@ SteamCommunity.prototype.getSteamSharedfile = function(sharedFileId, callback) {
|
|||||||
isDownvoted: null
|
isDownvoted: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Get DOM of sharedfile
|
// Get DOM of sharedfile
|
||||||
this.httpRequestGet(`https://steamcommunity.com/sharedfiles/filedetails/?id=${sharedFileId}`, (err, res, body) => {
|
this.httpRequestGet(`https://steamcommunity.com/sharedfiles/filedetails/?id=${sharedFileId}`, (err, res, body) => {
|
||||||
try {
|
try {
|
||||||
@ -121,15 +121,15 @@ SteamCommunity.prototype.getSteamSharedfile = function(sharedFileId, callback) {
|
|||||||
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")) {
|
if (breadcrumb.includes("Screenshot")) {
|
||||||
sharedfile.type = ESharedfileType.Screenshot;
|
sharedfile.type = ESharedFileType.Screenshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (breadcrumb.includes("Artwork")) {
|
if (breadcrumb.includes("Artwork")) {
|
||||||
sharedfile.type = ESharedfileType.Artwork;
|
sharedfile.type = ESharedFileType.Artwork;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (breadcrumb.includes("Guide")) {
|
if (breadcrumb.includes("Guide")) {
|
||||||
sharedfile.type = ESharedfileType.Guide;
|
sharedfile.type = ESharedFileType.Guide;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ SteamCommunity.prototype.getSteamSharedfile = function(sharedFileId, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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) {
|
||||||
@ -152,18 +152,18 @@ SteamCommunity.prototype.getSteamSharedfile = function(sharedFileId, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor - Creates a new Sharedfile object
|
* Constructor - Creates a new SharedFile object
|
||||||
* @class
|
* @class
|
||||||
* @param {SteamCommunity} community
|
* @param {SteamCommunity} community
|
||||||
* @param {{ id: string, type: ESharedfileType, appID: number, owner: SteamID|null, fileSize: string|null, postDate: number, resolution: string|null, uniqueVisitorsCount: number, favoritesCount: number, upvoteCount: number|null, guideNumRatings: Number|null, isUpvoted: boolean, isDownvoted: boolean }} data
|
* @param {{ id: string, type: ESharedFileType, appID: number, owner: SteamID|null, fileSize: string|null, postDate: number, resolution: string|null, uniqueVisitorsCount: number, favoritesCount: number, upvoteCount: number|null, guideNumRatings: Number|null, isUpvoted: boolean, isDownvoted: boolean }} data
|
||||||
*/
|
*/
|
||||||
function CSteamSharedfile(community, data) {
|
function CSteamSharedFile(community, data) {
|
||||||
/**
|
/**
|
||||||
* @type {SteamCommunity}
|
* @type {SteamCommunity}
|
||||||
*/
|
*/
|
||||||
this._community = community;
|
this._community = community;
|
||||||
|
|
||||||
// Clone all the data we recieved
|
// Clone all the data we received
|
||||||
Object.assign(this, data);
|
Object.assign(this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,16 +172,16 @@ function CSteamSharedfile(community, data) {
|
|||||||
* @param {String} cid - ID of the comment to delete
|
* @param {String} cid - ID of the comment to delete
|
||||||
* @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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Favorites this sharedfile
|
* Favorites this sharedfile
|
||||||
* @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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,30 +189,30 @@ CSteamSharedfile.prototype.favorite = function(callback) {
|
|||||||
* @param {String} message - Content of the comment to post
|
* @param {String} message - Content of the comment to post
|
||||||
* @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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes to this sharedfile's comment section. Note: Checkbox on webpage does not update
|
* Subscribes to this sharedfile's comment section. Note: Checkbox on webpage does not update
|
||||||
* @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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unfavorites this sharedfile
|
* Unfavorites this sharedfile
|
||||||
* @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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsubscribes from this sharedfile's comment section. Note: Checkbox on webpage does not update
|
* Unsubscribes from this sharedfile's comment section. Note: Checkbox on webpage does not update
|
||||||
* @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);
|
||||||
};
|
};
|
@ -1,6 +1,7 @@
|
|||||||
var SteamCommunity = require('../index.js');
|
|
||||||
var SteamID = require('steamid');
|
var SteamID = require('steamid');
|
||||||
|
|
||||||
|
var SteamCommunity = require('../index.js');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a comment from a sharedfile's comment section
|
* Deletes a comment from a sharedfile's comment section
|
||||||
@ -9,7 +10,7 @@ var SteamID = require('steamid');
|
|||||||
* @param {String} cid - ID of the comment to delete
|
* @param {String} cid - ID of the comment to delete
|
||||||
* @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, sharedFileId, cid, callback) {
|
SteamCommunity.prototype.deleteSharedFileComment = function(userID, sharedFileId, cid, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID === "string") {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
@ -26,7 +27,7 @@ SteamCommunity.prototype.deleteSharedfileComment = function(userID, sharedFileId
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ SteamCommunity.prototype.deleteSharedfileComment = function(userID, sharedFileId
|
|||||||
* @param {String} appid - ID of the app associated to this sharedfile
|
* @param {String} appid - ID of the app associated to this sharedfile
|
||||||
* @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(sharedFileId, appid, callback) {
|
SteamCommunity.prototype.favoriteSharedFile = function(sharedFileId, appid, callback) {
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/sharedfiles/favorite",
|
"uri": "https://steamcommunity.com/sharedfiles/favorite",
|
||||||
"form": {
|
"form": {
|
||||||
@ -49,7 +50,7 @@ SteamCommunity.prototype.favoriteSharedfile = function(sharedFileId, appid, call
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ SteamCommunity.prototype.favoriteSharedfile = function(sharedFileId, appid, call
|
|||||||
* @param {String} message - Content of the comment to post
|
* @param {String} message - Content of the comment to post
|
||||||
* @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, sharedFileId, message, callback) {
|
SteamCommunity.prototype.postSharedFileComment = function(userID, sharedFileId, message, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID === "string") {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
@ -77,7 +78,7 @@ SteamCommunity.prototype.postSharedfileComment = function(userID, sharedFileId,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ SteamCommunity.prototype.postSharedfileComment = function(userID, sharedFileId,
|
|||||||
* @param {String} sharedFileId ID of the sharedfile
|
* @param {String} sharedFileId ID of the sharedfile
|
||||||
* @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, sharedFileId, callback) {
|
SteamCommunity.prototype.subscribeSharedFileComments = function(userID, sharedFileId, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID === "string") {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
@ -103,7 +104,7 @@ SteamCommunity.prototype.subscribeSharedfileComments = function(userID, sharedFi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ SteamCommunity.prototype.subscribeSharedfileComments = function(userID, sharedFi
|
|||||||
* @param {String} appid - ID of the app associated to this sharedfile
|
* @param {String} appid - ID of the app associated to this sharedfile
|
||||||
* @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(sharedFileId, appid, callback) {
|
SteamCommunity.prototype.unfavoriteSharedFile = function(sharedFileId, appid, callback) {
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/sharedfiles/unfavorite",
|
"uri": "https://steamcommunity.com/sharedfiles/unfavorite",
|
||||||
"form": {
|
"form": {
|
||||||
@ -126,7 +127,7 @@ SteamCommunity.prototype.unfavoriteSharedfile = function(sharedFileId, appid, ca
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -136,7 +137,7 @@ SteamCommunity.prototype.unfavoriteSharedfile = function(sharedFileId, appid, ca
|
|||||||
* @param {String} sharedFileId - ID of the sharedfile
|
* @param {String} sharedFileId - ID of the sharedfile
|
||||||
* @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, sharedFileId, callback) {
|
SteamCommunity.prototype.unsubscribeSharedFileComments = function(userID, sharedFileId, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID === "string") {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
@ -152,6 +153,6 @@ SteamCommunity.prototype.unsubscribeSharedfileComments = function(userID, shared
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null || err);
|
callback(err);
|
||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
2
index.js
2
index.js
@ -590,7 +590,7 @@ require('./components/help.js');
|
|||||||
require('./classes/CMarketItem.js');
|
require('./classes/CMarketItem.js');
|
||||||
require('./classes/CMarketSearchResult.js');
|
require('./classes/CMarketSearchResult.js');
|
||||||
require('./classes/CSteamGroup.js');
|
require('./classes/CSteamGroup.js');
|
||||||
require('./classes/CSteamSharedfile.js');
|
require('./classes/CSteamSharedFile.js');
|
||||||
require('./classes/CSteamUser.js');
|
require('./classes/CSteamUser.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @enum ESharedfileType
|
* @enum ESharedFileType
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"Screenshot": 0,
|
"Screenshot": 0,
|
||||||
@ -10,4 +10,4 @@ module.exports = {
|
|||||||
"0": "Screenshot",
|
"0": "Screenshot",
|
||||||
"1": "Artwork",
|
"1": "Artwork",
|
||||||
"2": "Guide"
|
"2": "Guide"
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user