-
Notifications
You must be signed in to change notification settings - Fork 52
Settings abilities + small features #273
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
Conversation
I need to make different branches to make the pull requests to be more organised, since I accidentally made a pull request directly to my fork's main branch which means there are a lot of non-yt-to-scratch things here |
Actually, these are so many small features it would be quite messy to cherry pick them all. I'll just format the pr description nicely |
12 new features, all individually pretty small. Maybe this pr's description should be copy pasted for the docstrings lol |
Looks great. I'll merge this later today |
I only want to add features that benefit honest developers who are trying to create something unique. Changing passwords, changing email addresses and deleting accounts won't be added to scratchattach because the only practical use of this that I can come up with would be mass-stealing / mass-destroy other's accounts. |
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.
please remove this from the PR
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.
please remove this from the PR
I'll manually remove these myself |
The text from your PR is going straight to the documentation and docstrings, thanks! |
Oops, sorry for not responding earllier.. I need to find out how to use this github inbox thingy. Also maybe that honest developers thing should apply to the join_scratch function from sa-selenium, idk |
Oh, when you asked me to update the pr i was not available anyway (school ;-;) |
Settings abilities
(small features list below)
I found the post endpoints for the account settings menu. All of these features are part of the
session.Session
classDeleting accounts
You can delete an account by providing a delete mode and password (with cookies ofc) though
https://scratch.mit.edu/accounts/settings/delete_account/
. The deletion will be cancelled if you log back in on scratch or using the login function in scratchattach. I have not tested logging in by sessionid for this.NOTE: Joining, however, requires selenium (afaik) since you have to generate a g-recaptcha-code. It would be a feature of scralenium, a branch of scratchattach - but note that it's very much WIP since I can't use GitHub entirely properly lol
Setting your country
You can post at
https://scratch.mit.edu/accounts/settings/
to change the country of the account that the session is associated with.Changing your password
You can post at
https://scratch.mit.edu/accounts/password_change/
to change your password, using the old password and the new password. You will have to enter the old password yourself since the session object does not store the password.Logging out
Added a method of
session.Session
to send a logout request to scratch. This may not have any effect, although Scratch calls this url whenever you click 'Sign out'. The urlhttps://scratch.mit.edu/accounts/logout/
Email functionalities
Resending emails
You can ask to resend the email confirmation email as long as you have your password at
https://scratch.mit.edu/accounts/email_change/
. NOTE: Since I didn't want to make a new account, this feature has not properly been tested!Changing emails
You can change your email provided your password at
https://scratch.mit.edu/accounts/email_change/
.New email address
There is now a bs4-powered property to fetch the (possibly unconfirmed) email address that the session has requested to transfer to, i.e., if there is no unconfirmed email, it returns the current email (NOTE: The defaulting here hasn't been tested!). It reads this by sending a GET request to
https://scratch.mit.edu/accounts/email_change/
.Small features
YouTube link to scratch link
I often forget the exact URL to the scratch YouTube area so I made a function using urllib (part of the standard library) to parse a youtube url, allowing a few formats to cleanly convert it to a link to the form:
https://scratch.mit.edu/discuss/youtube/<video id>/
This adds 1 function (to site.forum since the url is part of the forums) called
youtube_link_to_scratch
and I made init.py import it tooEmbed url property
Added a
@property
toproject.Project
that simply concatenates/embed/
to the end of the project urlAdded outstanding email confirmation check
When a
Session
object calls_update_from_dict
, there are many attributes that are still left unused (should be added to a new pr). One of these is a check for whether the user has confirmed their email address.Resource APIs
I happened to find this json file that contains links to scratch learning resources in different languages:
https://resources.scratch.mit.edu/localized-urls.json
Reading ST member data
Reads the json data directly from the source which powers the credits page, which is the js file:
https://scratch.mit.edu/js/credits.bundle.js
, close to the bottom