Discuss Scratch

zaid1442011
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

https://github.com/TimMcCool/scratchattach/pull/230
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)

elip100 wrote:

(#2738)

TheCommCraft wrote:

(#2726)

elip100 wrote:

(#2674)

zaid1442011 wrote:

(#2674)
How can I get cloud variables of custom cloud servers?
Only Scratch and TurboWarp are supported
Wrong
Not wrong

zaid1442011 wrote:

(#2740)

TheCommCraft wrote:

elip100 wrote:

(#2674)

zaid1442011 wrote:

(#2674)
How can I get cloud variables of custom cloud servers?
Only Scratch and TurboWarp are supported
Wrong
How can I do it then?
It can be done using the cloud_host kwarg
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)


Random Project

spamton.gif





























DUNGEON_EXPLORATION_03_02_23_01
COMPILED VERSION FOR HIGHER SPEED
FutbolcuCiliPepe
Scratcher
6 posts

scratchattach - A Scratch API wrapper (Python)

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

Hi!

I am new to scratchattach. My test project only works while the python code was running. What can I do?
It's supposed to be like that or it will be impractical.
You can do:
while True:
    #Your code here will run till you close the python program
If you want to make a forever loop on Python.

Does it work if I close the python page? (And the code didn't work, are there any other solutions?)

What's the thing you are trying to make and what's your OS?

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.



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)

-effortIess- wrote:

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.

You could try
for user in list:
    print(user)
I'm not sure what you're currently doing though, so I could be wrong.

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)

TheCommCraft wrote:

(#2742)

zaid1442011 wrote:

(#2740)

TheCommCraft wrote:

elip100 wrote:

(#2674)

zaid1442011 wrote:

(#2674)
How can I get cloud variables of custom cloud servers?
Only Scratch and TurboWarp are supported
Wrong
How can I do it then?
It can be done using the cloud_host kwarg
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
This seams too cluttered.

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)

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

Hi!

I am new to scratchattach. My test project only works while the python code was running. What can I do?
It's supposed to be like that or it will be impractical.
You can do:
while True:
    #Your code here will run till you close the python program
If you want to make a forever loop on Python.

Does it work if I close the python page? (And the code didn't work, are there any other solutions?)

What's the thing you are trying to make and what's your OS?
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).

Likes: Programing (python scratch Lua c++ I am bad at c++ a) Aiviation (B787 Queen of the sky F35) Mountain Biking and Messing around with computers (not a gamer at all)
My projects I am most happy with also the few “polished games I have:
FutbolcuCiliPepe
Scratcher
6 posts

scratchattach - A Scratch API wrapper (Python)

wvzack wrote:

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

Hi!

I am new to scratchattach. My test project only works while the python code was running. What can I do?
It's supposed to be like that or it will be impractical.
You can do:
while True:
    #Your code here will run till you close the python program
If you want to make a forever loop on Python.

Does it work if I close the python page? (And the code didn't work, are there any other solutions?)

What's the thing you are trying to make and what's your OS?
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).

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)

jodon221 wrote:

can someone make a save system
For what?

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)

jodon221 wrote:

can someone make a save system
make it yourself! -thats the cool thing about coding

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)

TimMcCool wrote:

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.
I used to get a similar error with some python http library


9NAwRfSR-%dWFS$a$g&zBMTj2?;jvS?L5%^X%qpCX|A<*paJ=lU07c)wmt$v{TxL5



scratchGui.timeTravel.year = '2020'
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)

AlexDF16 wrote:

WHY DOES SCRATCH KEEP GIVING ME MESSAGES ABOUT THIS FORUM?
Your following it click Unfollow Discussion in the bottom right of the screen (why is this happening so much do people randomly follow it??)

Likes: Programing (python scratch Lua c++ I am bad at c++ a) Aiviation (B787 Queen of the sky F35) Mountain Biking and Messing around with computers (not a gamer at all)
My projects I am most happy with also the few “polished games I have:
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)

-effortIess- wrote:

How do you access studio activity? I keep getting ‘BadRequest’ errors.
Try
 
#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)


Likes: Programing (python scratch Lua c++ I am bad at c++ a) Aiviation (B787 Queen of the sky F35) Mountain Biking and Messing around with computers (not a gamer at all)
My projects I am most happy with also the few “polished games I have:
redspacecat
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

TimMcCool wrote:

I added a new page to scratchattach's wiki, it lists different hosting options: https://github.com/TimMcCool/scratchattach/wiki/Hosting
Can you add SillyDev as a free hosting service? It's similar to ScratchHost

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)

TimMcCool wrote:

I added a new page to scratchattach's wiki, it lists different hosting options: https://github.com/TimMcCool/scratchattach/wiki/Hosting
This will become handy someday

epic coder gamer 1000
fiosjeofo
Scratcher
11 posts

scratchattach - A Scratch API wrapper (Python)

NeonCoderFish wrote:

NeonCoderFish wrote:

MonkeyBean2 wrote:

elip100 wrote:

NeonCoderFish wrote:

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 anymore
It 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.
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
Also, 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.
everything is perfectly fine ( I checked ) but it just doesn't work
the other thing doesn't work either
maybe make sure the variable projectid is set to the correct one

when green flag clicked
forever
keep coding
have fun
scratch on!
end
define scratch(attach v)
(is cool v)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<(hi)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Powered by DjangoBB