Skip to content

Conversation

FAReTek1
Copy link
Collaborator

@FAReTek1 FAReTek1 commented Nov 7, 2024

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 class


Deleting 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 url https://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 too

Embed url property

Added a @property to project.Project that simply concatenates /embed/ to the end of the project url

Added 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

@FAReTek1 FAReTek1 closed this Nov 7, 2024
@FAReTek1
Copy link
Collaborator Author

FAReTek1 commented Nov 7, 2024

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

@FAReTek1 FAReTek1 reopened this Nov 7, 2024
@FAReTek1 FAReTek1 changed the title YouTube link to scratch forums link Settings abilities + small features Nov 7, 2024
@FAReTek1
Copy link
Collaborator Author

FAReTek1 commented Nov 7, 2024

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

@FAReTek1
Copy link
Collaborator Author

FAReTek1 commented Nov 7, 2024

12 new features, all individually pretty small. Maybe this pr's description should be copy pasted for the docstrings lol

@TimMcCool TimMcCool added the enhancement New feature or request label Nov 8, 2024
@TimMcCool
Copy link
Owner

Looks great. I'll merge this later today

@TimMcCool
Copy link
Owner

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.

Copy link
Owner

@TimMcCool TimMcCool left a 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

Copy link
Owner

@TimMcCool TimMcCool left a 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

@TimMcCool TimMcCool merged commit c3ff8d9 into TimMcCool:main Nov 8, 2024
@TimMcCool
Copy link
Owner

I'll manually remove these myself

@TimMcCool
Copy link
Owner

The text from your PR is going straight to the documentation and docstrings, thanks!

@FAReTek1
Copy link
Collaborator Author

FAReTek1 commented Nov 8, 2024

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

@FAReTek1
Copy link
Collaborator Author

FAReTek1 commented Nov 8, 2024

Oh, when you asked me to update the pr i was not available anyway (school ;-;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants