Discuss Scratch

jyotirmoy2020
Scratcher
2 posts

scratchclient - A scratch API wrapper for python

AdamKRPS425 wrote:

AdamKRPS425 wrote:

DifferentDance8 wrote:

AdamKRPS425 wrote:

AdamKRPS425 wrote:

im having trouble with editing cloud variables in my project, I don't get an error and the script keeps running but the variable does not change on Scratch

it's in my account, the project is shared and I'm logged in on the API (ScratchSession(“admkrps425”, “ThisIsToatalyMyRealPasswordNoCap”)) and I don't know what to do.

any help please


thanks in advance
hang on, does does the cloud variable need to start with the ☁ symbol?
i do not think so.
what could be the problem then?

I made a new script as a test and it gets stuck connecting to the project
this is the script
print("init")
from scratchclient import ScratchSession
print("logging on...")
session = ScratchSession("adamkrps425", "<placeholderpassword>")
print("connecting to project...")
connection = session.create_cloud_connection(726701801)
print("setting var...")
connection.set_cloud_variable("cloudVar", 1234)
print("done!")

and this is the console output

init
logging on…
connecting to project…
(still running as the posting of this btw its been like 5 min)


and as you see the cloud var on the project is still 0


The code you have given here perfectly works!
DifferentDance8
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

jyotirmoy2020 wrote:

The code you have given here perfectly works!
Like I just proved…

SOMEONE PLEASE HELP ME
TimMcCool
Scratcher
100+ posts

scratchclient - A scratch API wrapper for python

AdamKRPS425 wrote:

AdamKRPS425 wrote:

DifferentDance8 wrote:

AdamKRPS425 wrote:

AdamKRPS425 wrote:

im having trouble with editing cloud variables in my project, I don't get an error and the script keeps running but the variable does not change on Scratch

it's in my account, the project is shared and I'm logged in on the API (ScratchSession(“admkrps425”, “ThisIsToatalyMyRealPasswordNoCap”)) and I don't know what to do.

any help please


thanks in advance
hang on, does does the cloud variable need to start with the ☁ symbol?
i do not think so.
what could be the problem then?

I made a new script as a test and it gets stuck connecting to the project
this is the script
print("init")
from scratchclient import ScratchSession
print("logging on...")
session = ScratchSession("adamkrps425", "<placeholderpassword>")
print("connecting to project...")
connection = session.create_cloud_connection(726701801)
print("setting var...")
connection.set_cloud_variable("cloudVar", 1234)
print("done!")

and this is the console output

init
logging on…
connecting to project…
(still running as the posting of this btw its been like 5 min)


and as you see the cloud var on the project is still 0

Are you running the code on replit? Then it won't work. Scratch blocked replit from sending login request.

To set cloud variables with replit, you have to use cookie connect. I'm not sure if scratchclient has that feature, I couldn't find it in the documentation

Developer of scratchattach, the most popular Python Scratch API wrapper
TimMcCool
Scratcher
100+ posts

scratchclient - A scratch API wrapper for python

SomeoneOnThelnternet wrote:

mrcoat wrote:

SomeoneOnThelnternet wrote:

(#563)
Is it possible to add a session without my username and password? I want to use this to make a program but I don't want my password and stuff out there for anyone to see.
Depending on what you want to do, if you just want to see user/project stats then you just use scratch's api. But there isn't really a way to comment and interact with the website without using your password.
Ok, I just mainly want to see user followers and project stats and whatnot. How do I use the API?

i've never used scratchclient before now lol

To get your user / project stats, use @DatOneLefty's ScratchDB API:
https://scratchdb.lefty.one/v3/docs/#api-User-GetUserInfo

Example: (this will fetch your user stats)
import requests
stats = requests.get("https://scratchdb.lefty.one/v3/user/info/SomeoneOnThelnternet").json()

You can also get your user stats with scratchattach (doesn't require logging in) or scratchconnect:
import scratchattach as scratch3
user = scratch3.get_user("SomeoneOnTheInternet")
stats = user.stats()

Last edited by TimMcCool (Aug. 31, 2022 10:45:49)


Developer of scratchattach, the most popular Python Scratch API wrapper
DifferentDance8
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

I just made a script that follows and unfollows the account you choose to follow or unfollow.

from scratchclient import ScratchSession
username2 = input("Username? ")
password2 = input("Password? ")
session = ScratchSession(username2, password2)
follow_or_unfollow = input("Do you want to follow a user or unfollow a user? (\"y\" to follow, CASE SENSITIVE)")
if follow_or_unfollow == "y":
    print("Follow option selected!")
else:
    print("Unfollow option selected")
print("Enter in a user name")
user1 = input()
if follow_or_unfollow == "y":
    print(f"Following user {user1}...")
    session.get_user(user1).follow()
    print(f"User {user1} followed! Check your followers page! https://scratch.mit.edu/users/{username2}/following/")
    print("To follow or unfollow another user, run this script again!")
else:
    print(f"Unfollowing user {user1}")
    session.get_user(user1).unfollow()
    print(f"User {user1} followed! Check your followers page! https://scratch.mit.edu/users/{username2}/following/")
    print("To unfollow or follow another user, run this script again!")

So, if you wanted to follow gdpr0000001 using this script, you can!

SOMEONE PLEASE HELP ME
completeness
Scratcher
100+ posts

scratchclient - A scratch API wrapper for python

TimMcCool wrote:

SomeoneOnThelnternet wrote:

mrcoat wrote:

SomeoneOnThelnternet wrote:

(#563)
Is it possible to add a session without my username and password? I want to use this to make a program but I don't want my password and stuff out there for anyone to see.
Depending on what you want to do, if you just want to see user/project stats then you just use scratch's api. But there isn't really a way to comment and interact with the website without using your password.
Ok, I just mainly want to see user followers and project stats and whatnot. How do I use the API?

i've never used scratchclient before now lol

To get your user / project stats, use @DatOneLefty's ScratchDB API:
https://scratchdb.lefty.one/v3/docs/#api-User-GetUserInfo

You can use scratchclient for this now, I believe. ScratchSession doesn't require any parameters.
from scratchclient import ScratchSession
session = ScratchSession()
# User info
print(session.get_user("griffpatch"))
# Follower count
print(session.scraping.get_follower_count("griffpatch"))
Peterlll
Scratcher
11 posts

scratchclient - A scratch API wrapper for python

Are you guys really sure this can be used without risking a ban?
DifferentDance8
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

Peterlll wrote:

Are you guys really sure this can be used without risking a ban?
About as safe as using any other scratch python library!

SOMEONE PLEASE HELP ME
ZZC12345
Scratcher
500+ posts

scratchclient - A scratch API wrapper for python

Peterlll wrote:

Are you guys really sure this can be used without risking a ban?
Yes. There are so many cloud projects using this and similar libraries out there, and they're all still up.

This is my signature. Go check out my GitHub if you want to!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
god286
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

Peterlll wrote:

(#587)
Are you guys really sure this can be used without risking a ban?
If you use social actions, like following, loving/favouriting, commenting, etc. then that is not allowed and you may be warned/banned.
Other than that, for just getting data and cloud variables, it should be safe.

Here are some of my followers!

I joined: 5 years, 9 months, 24 days ago (31/03/2018)
I have: 479 followers
In total, I have attained: 1,403 loves, 1,145 favourites, and 33,731 views.
Fun Fact: If my account continued to gain followers at a similar rate to right now, in 14,210 years I would reach the number of followers griffpatch has today! Try to imagine how many followers he would have then!
Thank you everyone!
Script created by god286.
DifferentDance8
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

god286 wrote:

Peterlll wrote:

(#587)
Are you guys really sure this can be used without risking a ban?
If you use social actions, like following, loving/favouriting, commenting, etc. then that is not allowed and you may be warned/banned.
…oh boy, time to edit my post to remove the script!

SOMEONE PLEASE HELP ME
AdamKRPS425
Scratcher
43 posts

scratchclient - A scratch API wrapper for python

DifferentDance8 wrote:

AdamKRPS425 wrote:

really I would appreciate any help
Do you get a “scratchclient.ScratchExceptions.UnauthorizedException” error (meaning a 403, and I looked through the code), or a “scratchclient.ScratchExceptions.InvalidCredentialsException” error (meaning, well, your credentials are incorrect)?
I get this when posting the comment


and when changing a cloud variable the project just hangs, the console stays responsive but nothing happens. through testing I figured it got stuck on
connection = session.create_cloud_connection(726701801)

very unfortunately, my forum signature was eaten by an evil wizard and has now run away. please select this text and press ctrl+shift+down_key to view a animation




evil wizard code::events hat
forever
if <stolen forum signiture> then
laugh [he he he!] [quietly! v]
run!!!
end
end




















hi


hi!



hi!




————
| . . |
| ____ |
| / \|
————



————
| . . |
| ____ |
| |
————



————
| . . |
| \____/ |
| |
————





























































































you have reached the end of the animation.





























BYE!!!
AdamKRPS425
Scratcher
43 posts

scratchclient - A scratch API wrapper for python

TimMcCool wrote:

AdamKRPS425 wrote:

AdamKRPS425 wrote:

DifferentDance8 wrote:

AdamKRPS425 wrote:

AdamKRPS425 wrote:

im having trouble with editing cloud variables in my project, I don't get an error and the script keeps running but the variable does not change on Scratch

it's in my account, the project is shared and I'm logged in on the API (ScratchSession(“admkrps425”, “ThisIsToatalyMyRealPasswordNoCap”)) and I don't know what to do.

any help please


thanks in advance
hang on, does does the cloud variable need to start with the ☁ symbol?
i do not think so.
what could be the problem then?

I made a new script as a test and it gets stuck connecting to the project
this is the script
print("init")
from scratchclient import ScratchSession
print("logging on...")
session = ScratchSession("adamkrps425", "<placeholderpassword>")
print("connecting to project...")
connection = session.create_cloud_connection(726701801)
print("setting var...")
connection.set_cloud_variable("cloudVar", 1234)
print("done!")

and this is the console output

init
logging on…
connecting to project…
(still running as the posting of this btw its been like 5 min)


and as you see the cloud var on the project is still 0

Are you running the code on replit? Then it won't work. Scratch blocked replit from sending login request.

To set cloud variables with replit, you have to use cookie connect. I'm not sure if scratchclient has that feature, I couldn't find it in the documentation
nope, running it locally

very unfortunately, my forum signature was eaten by an evil wizard and has now run away. please select this text and press ctrl+shift+down_key to view a animation




evil wizard code::events hat
forever
if <stolen forum signiture> then
laugh [he he he!] [quietly! v]
run!!!
end
end




















hi


hi!



hi!




————
| . . |
| ____ |
| / \|
————



————
| . . |
| ____ |
| |
————



————
| . . |
| \____/ |
| |
————





























































































you have reached the end of the animation.





























BYE!!!
AdamKRPS425
Scratcher
43 posts

scratchclient - A scratch API wrapper for python

jyotirmoy2020 wrote:

AdamKRPS425 wrote:

AdamKRPS425 wrote:

DifferentDance8 wrote:

AdamKRPS425 wrote:

AdamKRPS425 wrote:

im having trouble with editing cloud variables in my project, I don't get an error and the script keeps running but the variable does not change on Scratch

it's in my account, the project is shared and I'm logged in on the API (ScratchSession(“admkrps425”, “ThisIsToatalyMyRealPasswordNoCap”)) and I don't know what to do.

any help please


thanks in advance
hang on, does does the cloud variable need to start with the ☁ symbol?
i do not think so.
what could be the problem then?

I made a new script as a test and it gets stuck connecting to the project
this is the script
print("init")
from scratchclient import ScratchSession
print("logging on...")
session = ScratchSession("adamkrps425", "<placeholderpassword>")
print("connecting to project...")
connection = session.create_cloud_connection(726701801)
print("setting var...")
connection.set_cloud_variable("cloudVar", 1234)
print("done!")

and this is the console output

init
logging on…
connecting to project…
(still running as the posting of this btw its been like 5 min)


and as you see the cloud var on the project is still 0


The code you have given here perfectly works!
does anyone have an idea as why it does not work for me? do I have to install something beside scrstchcliant? I run it in vs code do I need to run it directly in python? how long should it take?

very unfortunately, my forum signature was eaten by an evil wizard and has now run away. please select this text and press ctrl+shift+down_key to view a animation




evil wizard code::events hat
forever
if <stolen forum signiture> then
laugh [he he he!] [quietly! v]
run!!!
end
end




















hi


hi!



hi!




————
| . . |
| ____ |
| / \|
————



————
| . . |
| ____ |
| |
————



————
| . . |
| \____/ |
| |
————





























































































you have reached the end of the animation.





























BYE!!!
ZZC12345
Scratcher
500+ posts

scratchclient - A scratch API wrapper for python

AdamKRPS425 wrote:

jyotirmoy2020 wrote:

~snip~
The code you have given here perfectly works!
does anyone have an idea as why it does not work for me? do I have to install something beside scrstchcliant? I run it in vs code do I need to run it directly in python? how long should it take?
What's the error?

This is my signature. Go check out my GitHub if you want to!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
DifferentDance8
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

ZZC12345 wrote:

AdamKRPS425 wrote:

jyotirmoy2020 wrote:

~snip~
The code you have given here perfectly works!
does anyone have an idea as why it does not work for me? do I have to install something beside scrstchcliant? I run it in vs code do I need to run it directly in python? how long should it take?
What's the error?

AdamKRPS425 wrote:

I get this when posting the comment

SOMEONE PLEASE HELP ME
ZZC12345
Scratcher
500+ posts

scratchclient - A scratch API wrapper for python

DifferentDance8 wrote:

ZZC12345 wrote:

AdamKRPS425 wrote:

jyotirmoy2020 wrote:

~snip~
The code you have given here perfectly works!
does anyone have an idea as why it does not work for me? do I have to install something beside scrstchcliant? I run it in vs code do I need to run it directly in python? how long should it take?
What's the error?

AdamKRPS425 wrote:

I get this when posting the comment
Sorry!
Scratch returned a 403 error when you tried to post that comment. I'm not sure why.
https://github.com/CubeyTheCube/scratchclient/blob/cbabc79bbdeec1064e8de1c88480efdaebd5e1e7/scratchclient/User.py#L102-L103

This is my signature. Go check out my GitHub if you want to!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
NashwanYT
Scratcher
100+ posts

scratchclient - A scratch API wrapper for python

can u use pycharm it has inbuilt terminal and pip
DifferentDance8
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

NashwanYT wrote:

can u use pycharm it has inbuilt terminal and pip
Most of us would rather not pay 89 dollars USA for a product that can easily be replicated for 0 dollars USA with VSCode and a VSCode extension. Your choice, though.

SOMEONE PLEASE HELP ME
Chiroyce
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

DifferentDance8 wrote:

NashwanYT wrote:

can u use pycharm it has inbuilt terminal and pip
Most of us would rather not pay 89 dollars USA for a product that can easily be replicated for 0 dollars USA with VSCode and a VSCode extension. Your choice, though.
Bruh PyCharm is free https://www.jetbrains.com/pycharm/download/ — secondly if they already have the paid version then what is wrong with using PyCharm for this? PyCharm is designed for Python

I've seen this as a trend with your posts, just take this as advise and maybe look through sources a bit more when you post

Last edited by Chiroyce (Sept. 17, 2022 05:09:55)








April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence

Powered by DjangoBB