Discuss Scratch

Raihan142857
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

Yeetoburro1 wrote:

Hi, for some reason connecting to a project is taking infinitely long for me, wondering if this is a common issue or..
edit: king of the page hahaaha
what does your code look like

I use scratch.
GF: I'll dump you. BF: hex dump or binary dump?










wvj
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

Why do I need Microsoft Visual C++ 14.0? It gives me this error when I try to install it

    ERROR: Command errored out with exit status 1:
command: 'C:\Users\HP\AppData\Local\Programs\Python\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-hkqr6eia\\wsaccel_c8068a8ceae148a0ab7417482949925e\\setup.py'"'"'; __file__='"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-hkqr6eia\\wsaccel_c8068a8ceae148a0ab7417482949925e\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\HP\AppData\Local\Temp\pip-record-ylwetz90\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\HP\AppData\Local\Programs\Python\Python38-32\Include\wsaccel'
cwd: C:\Users\HP\AppData\Local\Temp\pip-install-hkqr6eia\wsaccel_c8068a8ceae148a0ab7417482949925e\
Complete output (10 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.8
creating build\lib.win32-3.8\wsaccel
copying wsaccel\__init__.py -> build\lib.win32-3.8\wsaccel
running build_ext
building 'wsaccel.utf8validator' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

Raihan142857
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

wvj wrote:

Why do I need Microsoft Visual C++ 14.0? It gives me this error when I try to install it

    ERROR: Command errored out with exit status 1:
command: 'C:\Users\HP\AppData\Local\Programs\Python\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-hkqr6eia\\wsaccel_c8068a8ceae148a0ab7417482949925e\\setup.py'"'"'; __file__='"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-hkqr6eia\\wsaccel_c8068a8ceae148a0ab7417482949925e\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\HP\AppData\Local\Temp\pip-record-ylwetz90\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\HP\AppData\Local\Programs\Python\Python38-32\Include\wsaccel'
cwd: C:\Users\HP\AppData\Local\Temp\pip-install-hkqr6eia\wsaccel_c8068a8ceae148a0ab7417482949925e\
Complete output (10 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.8
creating build\lib.win32-3.8\wsaccel
copying wsaccel\__init__.py -> build\lib.win32-3.8\wsaccel
running build_ext
building 'wsaccel.utf8validator' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
you don't need Microsoft Visual C++ 14.0. this seems to be an issue with wsaccel so i'd suggest you read their docs to see what happened

I use scratch.
GF: I'll dump you. BF: hex dump or binary dump?










Yeetoburro1
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

Raihan142857 wrote:

Yeetoburro1 wrote:

Hi, for some reason connecting to a project is taking infinitely long for me, wondering if this is a common issue or..
edit: king of the page hahaaha
what does your code look like
nvm fixed it

TheCloudDev
Scratcher
100+ posts

scratchclient - A scratch API wrapper for python

Raihan142857 wrote:

A few days ago I noticed there was no easy way to mess with scratch's API in Python so I created a python module to do this. https://pypi.org/project/scratchclient/

You can install it using
pip install scratchclient

Thanks to this npm package for the reference code and ilcheese2 for their modified version of my cloud code.

You can report issues on the github repo, this topic, or my scratch profile.

Usage:
Basic usage:
from scratchclient import ScratchSession
session = ScratchSession("ceebee", "--uwu--")
# post comments
session.get_user("Paddle2See").post_comment("OwO")
# lots of other stuff
print(session.get_project(450216269).get_comments()[0].content)
print(session.get_studio(29251822).description)
Cloud connection:
from scratchclient import ScratchSession
session = ScratchSession("griffpatch", "SecurePassword7")
connection = session.create_cloud_connection(450216269)
connection.set_cloud_variable("variable name", 5000)
@connection.on("set")
def on_set(variable):
    print(variable.name, variable.value)
print(connection.get_cloud_variable("other variable"))

I havent made documentation yet because I'm lazy so feel free to ask questions in this topic.
While trying to install scratch client, there is an error while installing wsaccel. It says I need C++ V14.0 or higher. What do I do?

Hi! I'm TheCloudDev
Raihan142857
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

TheCloudDev wrote:

Raihan142857 wrote:

A few days ago I noticed there was no easy way to mess with scratch's API in Python so I created a python module to do this. https://pypi.org/project/scratchclient/

You can install it using
pip install scratchclient

Thanks to this npm package for the reference code and ilcheese2 for their modified version of my cloud code.

You can report issues on the github repo, this topic, or my scratch profile.

Usage:
Basic usage:
from scratchclient import ScratchSession
session = ScratchSession("ceebee", "--uwu--")
# post comments
session.get_user("Paddle2See").post_comment("OwO")
# lots of other stuff
print(session.get_project(450216269).get_comments()[0].content)
print(session.get_studio(29251822).description)
Cloud connection:
from scratchclient import ScratchSession
session = ScratchSession("griffpatch", "SecurePassword7")
connection = session.create_cloud_connection(450216269)
connection.set_cloud_variable("variable name", 5000)
@connection.on("set")
def on_set(variable):
    print(variable.name, variable.value)
print(connection.get_cloud_variable("other variable"))

I havent made documentation yet because I'm lazy so feel free to ask questions in this topic.
While trying to install scratch client, there is an error while installing wsaccel. It says I need C++ V14.0 or higher. What do I do?
Not sure what else you should do except install C++ 14 or higher.

Later I might make an option to not use wsaccel but I'm not sure if PyPi will let me.

Last edited by Raihan142857 (May 27, 2021 12:54:37)


I use scratch.
GF: I'll dump you. BF: hex dump or binary dump?










Raihan142857
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

there are unfinished docs here

I use scratch.
GF: I'll dump you. BF: hex dump or binary dump?










Chiroyce
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

Raihan142857 wrote:

there are unfinished docs here
unfinished docs? you mean non-existent docs!!







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

My brain put the pieces together and I thought this was a scratched apple wrapper for python.
(Im tired and the text is small on my tv)

Anyways this is cool! Im gonna have to try it out! Node.js has been giving me… issues.

JackK211424
Scratcher
500+ posts

scratchclient - A scratch API wrapper for python

Chiroyce wrote:

Raihan142857 wrote:

there are unfinished docs here
unfinished docs? you mean non-existent docs!!
They exist, there is a sidebar with basic usage and stuff.

Chiroyce
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

JackK211424 wrote:

Chiroyce wrote:

Raihan142857 wrote:

there are unfinished docs here
unfinished docs? you mean non-existent docs!!
They exist, there is a sidebar with basic usage and stuff.
oooohhhhhhhh thanks







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
Maximouse
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

Raihan142857 wrote:

Not sure what else you should do except install C++ 14 or higher.
The error message probably said Visual C++ 14.0 or higher, which is not the same thing.

Last edited by Maximouse (May 27, 2021 14:37:54)



This is Maximouse's signature. Learn more about signatures.
TheCloudDev
Scratcher
100+ posts

scratchclient - A scratch API wrapper for python

Maximouse wrote:

Raihan142857 wrote:

Not sure what else you should do except install C++ 14 or higher.
The error message probably said Visual C++ 14.0 or higher, which is not the same thing.
So I install visual C++14.00?

Hi! I'm TheCloudDev
Maximouse
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

TheCloudDev wrote:

Maximouse wrote:

Raihan142857 wrote:

Not sure what else you should do except install C++ 14 or higher.
The error message probably said Visual C++ 14.0 or higher, which is not the same thing.
So I install visual C++14.00?
Yes. Here is the download link.


This is Maximouse's signature. Learn more about signatures.
wvj
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

it gives me this error when I try to log in
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 3, in <module>
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/scratchclient/ScratchSession.py", line 19, in __init__
self.login(password)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/scratchclient/ScratchSession.py", line 36, in login
self.session_id = re.search('"(.*)"', request.headers["Set-Cookie"]).group()
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/requests/structures.py", line 54, in __getitem__
return self._store[key.lower()][1]
KeyError: 'set-cookie'

[Program finished]


the code:
from scratchclient import ScratchSession
session = ScratchSession("wvj", "password")

My browser / operating system: Android Linux 11, Chrome 91.0.4472.101, No Flash version detected

Last edited by wvj (June 17, 2021 20:46:33)


Raihan142857
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

wvj wrote:

it gives me this error when I try to log in
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 3, in <module>
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/scratchclient/ScratchSession.py", line 19, in __init__
self.login(password)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/scratchclient/ScratchSession.py", line 36, in login
self.session_id = re.search('"(.*)"', request.headers["Set-Cookie"]).group()
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/requests/structures.py", line 54, in __getitem__
return self._store[key.lower()][1]
KeyError: 'set-cookie'

[Program finished]


the code:
from scratchclient import ScratchSession
session = ScratchSession("wvj", "password")

My browser / operating system: Android Linux 11, Chrome 91.0.4472.101, No Flash version detected
yes scratch broke something early yesterday, you have to reinstall the package (I fixed it this morning)

I use scratch.
GF: I'll dump you. BF: hex dump or binary dump?










wvj
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

Raihan142857 wrote:

wvj wrote:

it gives me this error when I try to log in
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 3, in <module>
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/scratchclient/ScratchSession.py", line 19, in __init__
self.login(password)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/scratchclient/ScratchSession.py", line 36, in login
self.session_id = re.search('"(.*)"', request.headers["Set-Cookie"]).group()
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/requests/structures.py", line 54, in __getitem__
return self._store[key.lower()][1]
KeyError: 'set-cookie'

[Program finished]


the code:
from scratchclient import ScratchSession
session = ScratchSession("wvj", "password")

My browser / operating system: Android Linux 11, Chrome 91.0.4472.101, No Flash version detected
yes scratch broke something early yesterday, you have to reinstall the package (I fixed it this morning)
Thanks, it works now!

JackK211424
Scratcher
500+ posts

scratchclient - A scratch API wrapper for python

I'm not sure if I'm being stupid but I'm getting a SSL certificate verify failed error and I'm not sure why.

Here is my code:
from scratchclient import ScratchSession
session = ScratchSession("JackK211424", "no password 4 u")
connection = session.create_cloud_connection(546297383)
@connection.on("set")
def on_set(variable):
    if variable.name == "Ping" and variable.value == 1:
        print("pinged")
        connection.set_cloud_variable("Ping", 0)

and here i the error:
Traceback (most recent call last):
File "/Users/jack/Development/Scratch requests/main.py", line 5, in <module>
connection = session.create_cloud_connection(546297383)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scratchclient/ScratchSession.py", line 138, in create_cloud_connection
return CloudConnection(project_id, self)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scratchclient/CloudConnection.py", line 20, in __init__
self.connect(project_id)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scratchclient/CloudConnection.py", line 31, in connect
self._ws.connect(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/websocket/_core.py", line 248, in connect
self.sock, addrs = connect(url, self.sock_opt, proxy_info(**options),
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/websocket/_http.py", line 121, in connect
sock = _ssl_socket(sock, options.sslopt, hostname)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/websocket/_http.py", line 256, in _ssl_socket
sock = _wrap_sni_socket(sock, sslopt, hostname, check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/websocket/_http.py", line 231, in _wrap_sni_socket
return context.wrap_socket(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1040, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)
Jacks-iMac:Scratch requests jack$ python3 main.py
Traceback (most recent call last):
File "/Users/jack/Development/Scratch requests/main.py", line 5, in <module>
connection = session.create_cloud_connection(546297383)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scratchclient/ScratchSession.py", line 138, in create_cloud_connection
return CloudConnection(project_id, self)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scratchclient/CloudConnection.py", line 20, in __init__
self.connect(project_id)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scratchclient/CloudConnection.py", line 31, in connect
self._ws.connect(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/websocket/_core.py", line 248, in connect
self.sock, addrs = connect(url, self.sock_opt, proxy_info(**options),
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/websocket/_http.py", line 121, in connect
sock = _ssl_socket(sock, options.sslopt, hostname)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/websocket/_http.py", line 256, in _ssl_socket
sock = _wrap_sni_socket(sock, sslopt, hostname, check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/websocket/_http.py", line 231, in _wrap_sni_socket
return context.wrap_socket(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1040, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)

Chiroyce
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

JackK211424 wrote:

Traceback (most recent call last):
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)
Basically your iMac has some invalid SSL certificate, so this seems like an issue with your device, and not scratchclient.

More on this here.

Last edited by Chiroyce (June 20, 2021 14:39:47)








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

King of da page yee

Chiroyce wrote:

JackK211424 wrote:

Traceback (most recent call last):
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)
Basically your iMac has some invalid SSL certificate, so this seems like an issue with your device, and not scratchclient.

More on this here.
Can you explain how to fix this?

The stackoverflow post you linked to says to “add CA in the trusted list for the requests library” and links to another post's answers, but none of them seem to explain how to do this. If Im missing something can you point it out to me?

Sidenote: speaking of stack overflow here is a little Easter egg (I think) at index.php

Last edited by JackK211424 (June 20, 2021 20:01:45)


Powered by DjangoBB

Standard | Mobile