-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add full sharedfiles support #306
Add full sharedfiles support #306
Conversation
Update: I have a nearly fully working scraper now. I'll add more details tomorrow and share a CSteamSharedfile implementation. |
Ooo, I've got something exciting to share! The scraper is able to get these values only by providing an id:
Two things are missing:
I'd also volunteer to write a Wiki page for this feature so you don't have to do that. |
If you quickly want to test it:
I haven't tested the methods with limited accounts yet. If anyone else wants to try out these changes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I've left a few comments.
classes/CSteamSharedfile.js
Outdated
// Find owner profile link, convert to steamID64 using SteamIdResolver lib and create a SteamID object | ||
let ownerHref = $(".friendBlockLinkOverlay").attr()["href"]; | ||
|
||
SteamIdResolver.customUrlToSteamID64(ownerHref, (err, steamID64) => { // This request takes <1 sec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to avoid adding additional dependencies if not absolutely required. Vanity URL resolving already exists here; you could move this to helpers.js and use it here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense. I have improved the function from getInventoryHistory()
to both accept full URLs and only the vanity. This makes it easier to use without needing to parse the input before calling it. It should not change the functionality but I wasn't able to test it as getInventoryHistory()
always returns Malformed page: no trade found
for me.
I would have preferred to use the lib as it made the integration easier but I get your point. The helper should have the same functionality now.
classes/CSteamSharedfile.js
Outdated
* Downvotes this sharedfile | ||
* @param {function} callback - Takes only an Error object/null as the first argument | ||
*/ | ||
CSteamSharedfile.prototype.voteDown = function(callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer to leave voteDown and voteUp out of the library. I want to try to maintain at least a tenuous good relationship with Valve, and the potential for abuse here seems too great. I also can't really think of a valid use-case for bot voting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I removed both functions
components/sharedfiles.js
Outdated
* @param {String} cid - ID of the comment to delete | ||
* @param {function} callback - Takes only an Error object/null as the first argument | ||
*/ | ||
SteamCommunity.prototype.deleteSharedfileComment = function(userID, sid, cid, callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sid
is kinda already known to be short for SteamID, could we call this parameter sharedFileId
or fileId
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, makes sense. I changed all sid
occurrences to sharedFileId
.
I have added support for determining if the user logged in has voted on a sharedfile and for reading the amount of ratings from guides, as they use a different rating system than screenshots & artworks. |
Merged changes from v3.44.4 & v3.45.0 into this branch and resolved conflicts. Would be cool if you could re-review as I made the changes requested. |
This PR adds support for posting comments, deleting comments, upvoting, downvoting, adding to favorites, removing from favorites, subscribing to comments and unsubscribing from comments on sharedfiles (screenshots, artworks, guides).
I've also included a currently disabled favorite & unfavorite function which is missing anappid
parameter, for reasons explained below.It is sadly not possible to "easily" fetch all available information using the "normal" xml way as Steam does not provide any
&xml=1
page for sharedfiles but we can scrape the DOM (see below!).I have therefore not added a class including angetSteamSharedfile()
function.The
favorite
&unfavorite
requests also demand anappid
header because all sharedfiles are associated to an app, which we can't figure out easily from just thesid
.While not being perfect, I think any sharedfiles support is better than none. At least commenting & voting works, which I think are the most interesting features.An idea which I'd like feedback on:
I could try to scrape the DOM for information about the sharedfile. This would allow for an
CSteamSharedfile
class, including angetSteamSharedfile()
function. It might be worth a try but I can't speak for any consistency or future proofness.What I was able to scrape with a simple test:
userID
parameters needed for posting comments, deleting comments, subscribing to comments and unsubscribing from comments!!favorite
&unfavorite
requests!I hope I didn't miss anything. Thanks for reading!
Edit: Oh and I hope it is ok that I opened the PR against master and not v4. If you'd rather have the changes in v4 then let me know and I'll make any necessary changes and open another PR.
Edit 2: Updated as I have now added full support using a scraper, see below.