Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » scratchattach - A Scratch API wrapper (Python)
- zaid1442011
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
https://github.com/TimMcCool/scratchattach/pull/230
https://github.com/TimMcCool/scratchattach/issues/231
https://github.com/TimMcCool/scratchattach/issues/231
I am a guy who codes weird stuff. Don’t check my GitHub only if you want stupid HTML pages (or something to host them). Check my platformer if you want to see something to see.
Profiles: GitHub.
You won't understand stuff in my signature because I talk about stuff in the ATs (Advanced Topics).
Check out this song for @griffpatch https://scratch.mit.edu/projects/887382049/
- TheCommCraft
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
(#2738)(#2726)Not wrong(#2674)Wrong(#2674)Only Scratch and TurboWarp are supported
How can I get cloud variables of custom cloud servers?
(#2740)It can be done using the cloud_host kwargHow can I do it then?(#2674)Wrong(#2674)Only Scratch and TurboWarp are supported
How can I get cloud variables of custom cloud servers?
Unless you mean the values and not a connection.
Edit: You could use a connection like this though:
try: conn = TwCloudConnection(project_id=project_id, _ws_timeout=1, purpose=purpose, contact=contact, cloud_host="yourcloudhost") data = conn.websocket.recv().split("\n") conn.disconnect() result = [] for i in data: try: result.append(json.loads(i)) except Exception: pass return result except websocket._exceptions.WebSocketTimeoutException: return [] except Exception: raise exceptions.FetchError
Last edited by TheCommCraft (Aug. 21, 2024 14:58:36)
- FutbolcuCiliPepe
- Scratcher
6 posts
scratchattach - A Scratch API wrapper (Python)
What's the thing you are trying to make and what's your OS?It's supposed to be like that or it will be impractical. Hi!
I am new to scratchattach. My test project only works while the python code was running. What can I do?
You can do:If you want to make a forever loop on Python.while True: #Your code here will run till you close the python program
Does it work if I close the python page? (And the code didn't work, are there any other solutions?)
I just want to know how to run scratchattach projects opening the python page (is this belongs to the platform i use?)
- -effortIess-
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
Hey I have a question.
So I was recently using sa to retrieve a list of managers from a studio. I retrieved the list successfully but the users were in the form of “user objects”. Any ideas on how to get a list of their actual usernames, and not just their SA IDs?
Also, I found out that if you print() one of the user objects it returns the username, but when you print() the whole list it returns a list of the user objects.
So I was recently using sa to retrieve a list of managers from a studio. I retrieved the list successfully but the users were in the form of “user objects”. Any ideas on how to get a list of their actual usernames, and not just their SA IDs?
Also, I found out that if you print() one of the user objects it returns the username, but when you print() the whole list it returns a list of the user objects.
✊ Support the suggestion HERE by adding this button to your signature ✊
BAN PI DAY!!! (joke)
100th post
- redspacecat
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
You could try Hey I have a question.
So I was recently using sa to retrieve a list of managers from a studio. I retrieved the list successfully but the users were in the form of “user objects”. Any ideas on how to get a list of their actual usernames, and not just their SA IDs?
Also, I found out that if you print() one of the user objects it returns the username, but when you print() the whole list it returns a list of the user objects.
for user in list: print(user)
Check out this Scratch 4.0 early beta release! | Also here's some cool rainbow text I made using this!
——————————————————————————————————————————————
Also please consider giving me an internet. (This image updates automatically every few hours)
You got TROLLED
- zaid1442011
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
(#2742)This seams too cluttered.(#2740)It can be done using the cloud_host kwargHow can I do it then?(#2674)Wrong(#2674)Only Scratch and TurboWarp are supported
How can I get cloud variables of custom cloud servers?
Unless you mean the values and not a connection.
Edit: You could use a connection like this though:try: conn = TwCloudConnection(project_id=project_id, _ws_timeout=1, purpose=purpose, contact=contact, cloud_host="yourcloudhost") data = conn.websocket.recv().split("\n") conn.disconnect() result = [] for i in data: try: result.append(json.loads(i)) except Exception: pass return result except websocket._exceptions.WebSocketTimeoutException: return [] except Exception: raise exceptions.FetchError
I made a pull request fixing this issue by adding the cloud host argument for the function. You can check it here.
I am a guy who codes weird stuff. Don’t check my GitHub only if you want stupid HTML pages (or something to host them). Check my platformer if you want to see something to see.
Profiles: GitHub.
You won't understand stuff in my signature because I talk about stuff in the ATs (Advanced Topics).
Check out this song for @griffpatch https://scratch.mit.edu/projects/887382049/
- wvzack
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
So from what I read you are using the python application instead of a editor I would recommend a editor like virtual studio code (not to be confused with virtual studio).What's the thing you are trying to make and what's your OS?It's supposed to be like that or it will be impractical. Hi!
I am new to scratchattach. My test project only works while the python code was running. What can I do?
You can do:If you want to make a forever loop on Python.while True: #Your code here will run till you close the python program
Does it work if I close the python page? (And the code didn't work, are there any other solutions?)
- FutbolcuCiliPepe
- Scratcher
6 posts
scratchattach - A Scratch API wrapper (Python)
So from what I read you are using the python application instead of a editor I would recommend a editor like virtual studio code (not to be confused with virtual studio).What's the thing you are trying to make and what's your OS?It's supposed to be like that or it will be impractical. Hi!
I am new to scratchattach. My test project only works while the python code was running. What can I do?
You can do:If you want to make a forever loop on Python.while True: #Your code here will run till you close the python program
Does it work if I close the python page? (And the code didn't work, are there any other solutions?)
I use it too but I didn't work. I tried to use replit (I know that it has a function that runs the project when you close the page, too)
- jodon221
- Scratcher
20 posts
scratchattach - A Scratch API wrapper (Python)
can someone make a save system
- redspacecat
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
For what? can someone make a save system
Check out this Scratch 4.0 early beta release! | Also here's some cool rainbow text I made using this!
——————————————————————————————————————————————
Also please consider giving me an internet. (This image updates automatically every few hours)
You got TROLLED
- dyptfolt314
- Scratcher
25 posts
scratchattach - A Scratch API wrapper (Python)
make it yourself! -thats the cool thing about coding can someone make a save system
send packets through cloud variables that can be recieved and turned into an object/list and store in a txt file/json/db with os, sql or some other library. then use a search function to find the user's id/username in the file and send a packet back of all their data.
Last edited by dyptfolt314 (Aug. 27, 2024 15:42:55)
- -effortIess-
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
How do you access studio activity? I keep getting ‘BadRequest’ errors.
✊ Support the suggestion HERE by adding this button to your signature ✊
BAN PI DAY!!! (joke)
100th post
- MonkeyBean2
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
I used to get a similar error with some python http library In the past, many people reported they were unable to connect to Scratch's cloud variables because they got this error:ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)
I was never able to reproduce the error - until I recently stumbled upon it myself on a new device. I found a way to fix it which will be implemented in scratchattach soon / in a future update.
- AlexDF16
- Scratcher
9 posts
scratchattach - A Scratch API wrapper (Python)
WHY DOES SCRATCH KEEP GIVING ME MESSAGES ABOUT THIS FORUM?
Last edited by AlexDF16 (Aug. 31, 2024 13:54:29)
- wvzack
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
Your following it click Unfollow Discussion in the bottom right of the screen (why is this happening so much do people randomly follow it??) WHY DOES SCRATCH KEEP GIVING ME MESSAGES ABOUT THIS FORUM?
- TimMcCool
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
I added a new page to scratchattach's wiki, it lists different hosting options: https://github.com/TimMcCool/scratchattach/wiki/Hosting
Last edited by TimMcCool (Aug. 31, 2024 14:03:04)
Developer of scratchattach, the most popular Python Scratch API wrapper
- wvzack
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
Try How do you access studio activity? I keep getting ‘BadRequest’ errors.
#put in your login scripts here
studio = session.connect_studio(studio_id) #the number that comes after the url eg. https://scratch.mit.edu/studios/#########/
print(studio.activity(limit=24, offset=0))
If this doesn't work try upgrading scratchattach.
Last edited by wvzack (Aug. 31, 2024 14:14:28)
- redspacecat
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
https://github.com/TimMcCool/scratchattach/wiki/HostingCan you add SillyDev as a free hosting service? It's similar to ScratchHost I added a new page to scratchattach's wiki, it lists different hosting options:
Check out this Scratch 4.0 early beta release! | Also here's some cool rainbow text I made using this!
——————————————————————————————————————————————
Also please consider giving me an internet. (This image updates automatically every few hours)
You got TROLLED
- EpicCoderGamer1000
- Scratcher
79 posts
scratchattach - A Scratch API wrapper (Python)
https://github.com/TimMcCool/scratchattach/wiki/HostingThis will become handy someday I added a new page to scratchattach's wiki, it lists different hosting options:
epic coder gamer 1000
- fiosjeofo
- Scratcher
11 posts
scratchattach - A Scratch API wrapper (Python)
maybe make sure the variable projectid is set to the correct onethe other thing doesn't work eithereverything is perfectly fine ( I checked ) but it just doesn't workIt is failing to get the “arg” variable from the project. Make sure the variable exists, is a cloud variable, and you are correctly connected to the project. project = session.connect_project(int(scratch3.get_var(projectid, “arg”)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not ‘NoneType’
I don't like python anymoreAlso, consider using scratchattach cloud requests instead of getting the value of “arg” - it will make it much easier to add new features in the future.argProjectID = scratch3.get_var(projectid, "arg") if argProjectID: project = session.connect_project(int(argProjectID)) # continue using project, make sure to put the rest of your code that uses this variable in here, unless you make it default to something else: # argProjectID is None, variable "arg" does not exist in the project projectid
when green flag clicked
forever
keep coding
have fun
scratch on!
end
define scratch(attach v)
(is cool v)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<(hi)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- Discussion Forums
- » Advanced Topics
- » scratchattach - A Scratch API wrapper (Python)