Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » scratchclient - A scratch API wrapper for python
- NFlex23
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Now I got another error, this time it was about Scratchclient:
Exception in thread Thread-2: Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/scratchclient/CloudConnection.py", line 100, in _cloud_var_loop response = self._ws.recv() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_core.py", line 354, in recv opcode, data = self.recv_data() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_core.py", line 377, in recv_data opcode, frame = self.recv_data_frame(control_frame) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_core.py", line 396, in recv_data_frame frame = self.recv_frame() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_core.py", line 435, in recv_frame return self.frame_buffer.recv_frame() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_abnf.py", line 337, in recv_frame self.recv_header() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_abnf.py", line 293, in recv_header header = self.recv_strict(2) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_abnf.py", line 372, in recv_strict bytes_ = self.recv(min(16384, shortage)) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_core.py", line 519, in _recv return recv(self.sock, bufsize) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_socket.py", line 125, in recv raise WebSocketConnectionClosedException( websocket._exceptions.WebSocketConnectionClosedException: Connection to remote host was lost.
Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.
- Chiroyce
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
seems like an issue with your network connection - WiFi issues I guess? Or the Scratch websocket server cutting the connection. websocket._exceptions.WebSocketConnectionClosedException: Connection to remote host was lost.
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
- ScratchCatHELLO
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Now I got another error, this time it was about Scratchclient:Exception in thread Thread-2: Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/scratchclient/CloudConnection.py", line 100, in _cloud_var_loop response = self._ws.recv() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_core.py", line 354, in recv opcode, data = self.recv_data() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_core.py", line 377, in recv_data opcode, frame = self.recv_data_frame(control_frame) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_core.py", line 396, in recv_data_frame frame = self.recv_frame() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_core.py", line 435, in recv_frame return self.frame_buffer.recv_frame() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_abnf.py", line 337, in recv_frame self.recv_header() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_abnf.py", line 293, in recv_header header = self.recv_strict(2) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_abnf.py", line 372, in recv_strict bytes_ = self.recv(min(16384, shortage)) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_core.py", line 519, in _recv return recv(self.sock, bufsize) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/websocket/_socket.py", line 125, in recv raise WebSocketConnectionClosedException( websocket._exceptions.WebSocketConnectionClosedException: Connection to remote host was lost.
check your wifi connection
ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust
Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
- Goldtabby
- Scratcher
93 posts
scratchclient - A scratch API wrapper for python
Ok soo… I get this error:
Traceback (most recent call last):
File “CUsers/user/OneDrive/Desktop/ScratchToPython Server.py”, line 3, in <module>
session = ScratchSession(“goldtabby”, “–pass–”)
File “C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\scratchclient\ScratchSession.py”, line 19, in __init__
self.login(password)
File “C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\scratchclient\ScratchSession.py”, line 36, in login
self.session_id = re.search('“(.*)”', request.headers).group()
File “C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\structures.py”, line 54, in __getitem__
return self._store
KeyError: ‘set-cookie’
For this code:
from scratchclient import ScratchSession
session = ScratchSession(“goldtabby”, “–pass–”)
print(session.get_project(513007591).get_comments().content)
Traceback (most recent call last):
File “CUsers/user/OneDrive/Desktop/ScratchToPython Server.py”, line 3, in <module>
session = ScratchSession(“goldtabby”, “–pass–”)
File “C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\scratchclient\ScratchSession.py”, line 19, in __init__
self.login(password)
File “C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\scratchclient\ScratchSession.py”, line 36, in login
self.session_id = re.search('“(.*)”', request.headers).group()
File “C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\structures.py”, line 54, in __getitem__
return self._store
KeyError: ‘set-cookie’
For this code:
from scratchclient import ScratchSession
session = ScratchSession(“goldtabby”, “–pass–”)
print(session.get_project(513007591).get_comments().content)
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/
- ScratchCatHELLO
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Ok soo… I get this error:For this code:Traceback (most recent call last): File "C:/Users/user/OneDrive/Desktop/ScratchToPython Server.py", line 3, in <module> session = ScratchSession("goldtabby", "--pass--") File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\scratchclient\ScratchSession.py", line 19, in __init__ self.login(password) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\scratchclient\ScratchSession.py", line 36, in login self.session_id = re.search('"(.*)"', request.headers["Set-Cookie"]).group() File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\structures.py", line 54, in __getitem__ return self._store[key.lower()][1] KeyError: 'set-cookie'from scratchclient import ScratchSession session = ScratchSession("goldtabby", "--pass--") print(session.get_project(513007591).get_comments()[0].content)
this is the code where the error occurs:
def login(self, password): # logs in to Scratch headers = { "x-csrftoken": "a", "x-requested-with": "XMLHttpRequest", "Cookie": "scratchcsrftoken=a;scratchlanguage=en;", "referer": "https://scratch.mit.edu", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36" } data = json.dumps({"username": self.username, "password": password}) request = requests.post( "https://scratch.mit.edu/login/", data=data, headers=headers ) try: self.session_id = re.search('"(.*)"', request.headers["Set-Cookie"]).group() // error here self.token = request.json()[0]["token"] except AttributeError: raise InvalidCredentialsException("Your password or username is incorrect")
Last edited by ScratchCatHELLO (Aug. 30, 2021 19:28:31)
ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust
Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
- NFlex23
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
It's not my WiFi, it's running on Replit.seems like an issue with your network connection - WiFi issues I guess? Or the Scratch websocket server cutting the connection. websocket._exceptions.WebSocketConnectionClosedException: Connection to remote host was lost.
Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.
- Chiroyce
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Restart the repl and try again. Also how long was the connection there for before it went? It's not my WiFi, it's running on Replit.
seems like scratchclient only handles AttributeError and not KeyError something went wrong with the request, but not in a way that scratchclient knows how to handle. I’ve never looked the format of this sort of request, so I don’t know why this happens, but you could try checking if your password was correct.
Last edited by Chiroyce (Aug. 31, 2021 03:06:37)
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
- NFlex23
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
A long time, maybe like 2 days? Also how long was the connection there for before it went?
Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.
- Chiroyce
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Seems like the server may have disconnected you from the connection - I don't really know, does restarting it fix it? A long time, maybe like 2 days?
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
- NFlex23
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Yeah, it works now.Seems like the server may have disconnected you from the connection - I don't really know, does restarting it fix it? A long time, maybe like 2 days?
Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.
- ScratchCatHELLO
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
A long time, maybe like 2 days? Also how long was the connection there for before it went?
it probably timed out. you could try modifying the code so that it disconnects and reconnects after a certain amount of time.
ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust
Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
- NFlex23
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Quick question: Can you change a project's cloud variables with any account, even if it's not the project's account? If so, that seems like a major “security” risk for cloud projects with leaderboards.
Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.
- Raihan142857
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Yeah, you can. I'm pretty sure you can also set cloud variables with a new Scratcher account. Quick question: Can you change a project's cloud variables with any account, even if it's not the project's account? If so, that seems like a major “security” risk for cloud projects with leaderboards.
I use scratch.
GF: I'll dump you. BF: hex dump or binary dump?
- NFlex23
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Wow, OK.Yeah, you can. I'm pretty sure you can also set cloud variables with a new Scratcher account. Quick question: Can you change a project's cloud variables with any account, even if it's not the project's account? If so, that seems like a major “security” risk for cloud projects with leaderboards.
Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.
- ScratchCatHELLO
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Quick question: Can you change a project's cloud variables with any account, even if it's not the project's account? If so, that seems like a major “security” risk for cloud projects with leaderboards.
that’s a scratch api problem though, not a scratchclient problem.
ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust
Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
- Chiroyce
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
yeah you can and the scratch team KNOWS about this and yet they dont do anything about it Quick question: Can you change a project's cloud variables with any account, even if it's not the project's account? If so, that seems like a major “security” risk for cloud projects with leaderboards.
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
- JackK211424
- Scratcher
500+ posts
scratchclient - A scratch API wrapper for python
Let me re-phrase that. They cant do anything about it.yeah you can and the scratch team KNOWS about this and yet they dont do anything about it Quick question: Can you change a project's cloud variables with any account, even if it's not the project's account? If so, that seems like a major “security” risk for cloud projects with leaderboards.
Due to the nature of the internet, anybody can use anything assuming the requests are public, which scratch's cloud is. With the way scratch's cloud works, anybody running a project can modify a variable, but there is no way to completely prevent outside applications from doing so as well, you can make it harder, but you cant really make it impossible.
Last edited by JackK211424 (Sept. 1, 2021 12:52:44)
- Chiroyce
- Scratcher
1000+ posts
scratchclient - A scratch API wrapper for python
Nothing is impossible Let me re-phrase that. They cant do anything about it.
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