Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » scratchclient - A scratch API wrapper for python
- mrcoat
- Scratcher
100+ posts
scratchclient - A scratch API wrapper for python
Ya I'm switching to something that doesn't require visual c++Also I'm having the same problem. I decided to switch the module I'm using to scratch2py How do I handle errors such as invalid variable name?
My cartoon
Watch My Show!
I was gonna put an image of the studio but it didn't work.
Cool thing I made
when [Awesomeness v] > (100)
forever
play sound [Victory v] until done
set rotation style [The best style v]
go to [The party v]
end
- Sid72020123
- Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
Will you use scratchconnect or scratch2py?Ya I'm switching to something that doesn't require visual c++Also I'm having the same problem. I decided to switch the module I'm using to scratch2py How do I handle errors such as invalid variable name?
Sid72020123
- mrcoat
- Scratcher
100+ posts
scratchclient - A scratch API wrapper for python
Not sure yet, I want to do a bit o research.Will you use scratchconnect or scratch2py?Ya I'm switching to something that doesn't require visual c++Also I'm having the same problem. I decided to switch the module I'm using to scratch2py How do I handle errors such as invalid variable name?
My cartoon
Watch My Show!
I was gonna put an image of the studio but it didn't work.
Cool thing I made
when [Awesomeness v] > (100)
forever
play sound [Victory v] until done
set rotation style [The best style v]
go to [The party v]
end
- Sid72020123
- Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
Ok!Not sure yet, I want to do a bit o research.Will you use scratchconnect or scratch2py?Ya I'm switching to something that doesn't require visual c++Also I'm having the same problem. I decided to switch the module I'm using to scratch2py How do I handle errors such as invalid variable name?
Sid72020123
- hubblefam
- Scratcher
45 posts
scratchclient - A scratch API wrapper for python
so when i run the thing to change a cloud variable the program does not give me an error but it does not do anything.
the code:
from scratchclient import ScratchSession
session = ScratchSession(“Hubblefam”, “#########”)
connection = session.create_cloud_connection(596965016)
connection.set_cloud_variable(“CLOUD”, 1)
@connection.on(“set”)
def on_set(variable):
print(variable.name, variable.value)
print(connection.get_cloud_variable(“CLOUD”))
the code:
from scratchclient import ScratchSession
session = ScratchSession(“Hubblefam”, “#########”)
connection = session.create_cloud_connection(596965016)
connection.set_cloud_variable(“CLOUD”, 1)
@connection.on(“set”)
def on_set(variable):
print(variable.name, variable.value)
print(connection.get_cloud_variable(“CLOUD”))
- Goldtabby
- Scratcher
93 posts
scratchclient - A scratch API wrapper for python
I am just going to make my own Scratch/Python API Module….
when green flag clickedThis is my Site! Check it out!
say [I make good quality projects!]
think [most of the time...]
say [come check them out!]
This is my profile! Come follow me!
Wireframe ship pro here: https://scratch.mit.edu/projects/369638452/
- vikkcd
- Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
Good luck. I am just going to make my own Scratch/Python API Module….
Coder, Animator, Artist
Love Michael Jackson and OK GO music.
forever
Fold Origami
Listen to Michael Jackson and OK GO
Play guitar
end
- Chiroyce
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
For @dhuls since they asked here
# after logging in and connecting to project @connection.on("set") def on_set(variable): print(f'{variable.name} has been set to {variable.value}') # variable.name is the name of the variable that was changed # variable.value is the value the variable was set to
Last edited by Chiroyce (Nov. 10, 2021 06:22:51)
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
- Goldtabby
- Scratcher
93 posts
scratchclient - A scratch API wrapper for python
Not that heard, I already startedGood luck. I am just going to make my own Scratch/Python API Module….
when green flag clickedThis is my Site! Check it out!
say [I make good quality projects!]
think [most of the time...]
say [come check them out!]
This is my profile! Come follow me!
Wireframe ship pro here: https://scratch.mit.edu/projects/369638452/
- nini2009ph
- Scratcher
87 posts
scratchclient - A scratch API wrapper for python
Data = session.get_user(“nini2009ph”).get_followers()
for i in Data:
print(i.username)
session.get_studio(30610675).invite_curator(i.username)
error: self.owner = data KeyError: ‘owner’
for i in Data:
print(i.username)
session.get_studio(30610675).invite_curator(i.username)
error: self.owner = data KeyError: ‘owner’
Last edited by nini2009ph (Nov. 12, 2021 17:21:54)
- nini2009ph
- Scratcher
87 posts
scratchclient - A scratch API wrapper for python
i did something in the scratch client code and now it works Data = session.get_user(“nini2009ph”).get_followers()
for i in Data:
print(i.username)
session.get_studio(30610675).invite_curator(i.username)
error: self.owner = data KeyError: ‘owner’
- Shawn12344
- Scratcher
5 posts
scratchclient - A scratch API wrapper for python
Hello can i get some help with an error i keep getting. the error i get is websocket._exceptions.websocketconnectionclosedexception: connection to remote host was lost. i get the error after my code has been running for about 10+ hours.
- JackK211424
- Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
I'm pretty sure that scratch closes the cloud connection after a time. The only way to fix this would be to use the Try: Except: anytime you use a request and if you get an error then reconnect. Hello can i get some help with an error i keep getting. the error i get is websocket._exceptions.websocketconnectionclosedexception: connection to remote host was lost. i get the error after my code has been running for about 10+ hours.
- vikkcd
- Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
right so scratch2py is too slow and is a bit too buggy for my liking. Lets try Scratch connect.
edit: so im stuck on the creating a connection with a project because I type in
HeadProject = ServerUser.connect_project(project_id=586832024)
and it keeps telling me that the project doesn't exist even though it does.
edit: so im stuck on the creating a connection with a project because I type in
HeadProject = ServerUser.connect_project(project_id=586832024)
and it keeps telling me that the project doesn't exist even though it does.
Last edited by vikkcd (Nov. 14, 2021 15:11:58)
Coder, Animator, Artist
Love Michael Jackson and OK GO music.
forever
Fold Origami
Listen to Michael Jackson and OK GO
Play guitar
end
- ajsya
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
You might need to share the project… right so scratch2py is too slow and is a bit too buggy for my liking. Lets try Scratch connect.
edit: so im stuck on the creating a connection with a project because I type in
HeadProject = ServerUser.connect_project(project_id=586832024)
and it keeps telling me that the project doesn't exist even though it does.
- vikkcd
- Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
sureYou might need to share the project… right so scratch2py is too slow and is a bit too buggy for my liking. Lets try Scratch connect.
edit: so im stuck on the creating a connection with a project because I type in
HeadProject = ServerUser.connect_project(project_id=586832024)
and it keeps telling me that the project doesn't exist even though it does.
Coder, Animator, Artist
Love Michael Jackson and OK GO music.
forever
Fold Origami
Listen to Michael Jackson and OK GO
Play guitar
end
- -EmeraldThunder-
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
I've been making a pfp loader and have stumbled across a problem. The connection times out and gives me an error I would normally like to catch this error using a try statement and restart the main function although I am only using one function tied to the @connection.on('set') decorator. How can I catch a timeout and cause a restart.
@connection.on('set') def main(variable): if variable.name[2:] == "Request": print(f'Received: {variable.value}') pfp = requests.get(f'https://api.scratch.mit.edu/users/{decode(variable.value)[0]}/').json()['profile']['images']['60x60'] image = Image.open(requests.get(pfp, stream=True).raw) width, height = image.size values = list(image.getdata()) send(values, width, height) connection.set_cloud_variable('Serving', int(connection.get_cloud_variable('Serving')) + 1)
Nothing here.
- ajsya
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
wouldn't you do: I've been making a pfp loader and have stumbled across a problem. The connection times out and gives me an error I would normally like to catch this error using a try statement and restart the main function although I am only using one function tied to the @connection.on('set') decorator. How can I catch a timeout and cause a restart.@connection.on('set') def main(variable): if variable.name[2:] == "Request": print(f'Received: {variable.value}') pfp = requests.get(f'https://api.scratch.mit.edu/users/{decode(variable.value)[0]}/').json()['profile']['images']['60x60'] image = Image.open(requests.get(pfp, stream=True).raw) width, height = image.size values = list(image.getdata()) send(values, width, height) connection.set_cloud_variable('Serving', int(connection.get_cloud_variable('Serving')) + 1)
try: #your function except TimeoutError: #do function again or whatever else here
Last edited by ajsya (Nov. 14, 2021 16:15:03)
- Sid72020123
- Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
Yes! The project needs to be shared.sureYou might need to share the project… right so scratch2py is too slow and is a bit too buggy for my liking. Lets try Scratch connect.
edit: so im stuck on the creating a connection with a project because I type in
HeadProject = ServerUser.connect_project(project_id=586832024)
and it keeps telling me that the project doesn't exist even though it does.
Sid72020123