Discuss Scratch

Chiroyce
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

StevoSure wrote:

can anyone tell me the thing that is wrong here?



what error do you get?
nikoniko0826
Scratcher
16 posts

scratchclient - A scratch API wrapper for python

完全 wrote:

nikoniko0826 wrote:

Please tell me the code to attach stars and hearts to Project.
this is technically not allowed, but I'm guessing you're interested for educational purposes
from scratchclient import ScratchSession
session = ScratchSession("username", "password")
project = session.get_project(<put your project ID here>)
project.love()
project.favorite()
Should I enter this code into Python?
nikoniko0826
Scratcher
16 posts

scratchclient - A scratch API wrapper for python

nikoniko0826 wrote:

(#626)

completeness wrote:

nikoniko0826 wrote:

Please tell me the code to attach stars and hearts to Project.
this is technically not allowed, but I'm guessing you're interested for educational purposes
from scratchclient import ScratchSession
session = ScratchSession("username", "password")
project = session.get_project(<put your project ID here>)
project.love()
project.favorite()
Should I enter this code into Python?
mrcoat
Scratcher
100+ posts

scratchclient - A scratch API wrapper for python

nikoniko0826 wrote:

nikoniko0826 wrote:

(#626)

completeness wrote:

nikoniko0826 wrote:

Please tell me the code to attach stars and hearts to Project.
this is technically not allowed, but I'm guessing you're interested for educational purposes
from scratchclient import ScratchSession
session = ScratchSession("username", "password")
project = session.get_project(<put your project ID here>)
project.love()
project.favorite()
Should I enter this code into Python?
Yes
myscript423
Scratcher
37 posts

scratchclient - A scratch API wrapper for python

ATTENTION ALL PYTHON 3 USERS HOPING TO GET THIS:
use:
pip3 install scratchclient
instead of:
pip install scratchclient
~small difference, yet only works this way~
ninjaMAR
Scratcher
1000+ posts

scratchclient - A scratch API wrapper for python

myscript423 wrote:

(#629)
ATTENTION ALL PYTHON 3 USERS HOPING TO GET THIS:
use:
pip3 install scratchclient
instead of:
pip install scratchclient
~small difference, yet only works this way~
This is incorrect. pip and pip3 could correspond to different versions of python. My system used to have multiple versions of python (until I cleaned it up), each with it's own version of pip. “python” referenced python2.7, “python3.9” referenced python3.9, and “python3” referenced python3.11. Pip was a mess. “pip3” pointed to python3.9, and “pip” pointed to python3.11. Pip and pip3 aren't always interchangeable. The best way to verify you have the correct installation is to run.
python3 -m pip --version
and make sure the output matches the result running\
pip --version
What complicates things even further, is that you can change the interpreter for a different version of pip. In conclusion, while the code that you provided may work only for you, it won't work for everyone.
ThePersonScratcher
Scratcher
0 posts

scratchclient - A scratch API wrapper for python

HEEHEE HAHA

mega_micro_2
New Scratcher
1 post

scratchclient - A scratch API wrapper for python

I get this error when trying to delete a comment (or reply to a comment, but this is the case where I try to delete one):
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File "C:\Users\XXXXX\AppData\Roaming\Python\Python312\site-packages\scratchclient\Comment.py“, line 155, in delete
self._comment_action(”del“, self.id, self.user, self._client)
File ”C:\Users\XXXXX\AppData\Roaming\Python\Python312\site-packages\scratchclient\Comment.py", line 139, in _comment_action
client._ensure_logged_in()
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: ‘str’ object has no attribute ‘_ensure_logged_in’
The code:
comment = session.scraping.get_profile_comments(“mega_micro_2”)[0 # I didn't close the square bracket because forum formatting didn't like that
comment.delete()
AdamKRPS425
Scratcher
44 posts

scratchclient - A scratch API wrapper for python

AdamKRPS425 wrote:

BlueNoodle29 wrote:

I noticed that with some scratch projects, attempting to establish a cloud connection yields an infinite waiting cycle. Any idea why this may be?
This happens to me - EVERY TIME its very annoying, someone please help with this
Does this happen to anyone else? I haven't retried in a while but I don't know if this still is an issue
nikoniko0826
Scratcher
16 posts

scratchclient - A scratch API wrapper for python

I typed the code 「
import scratchconnect
import datetime

user = scratchconnect.ScratchConnect(“nikoniko0826”, “########”)
project = user.connect_project(project_id=##########)
variables = project.connect_cloud_variables()
date=datetime.datetime.now()
this=datetime.date.today()
print(this)
set= variables.set_cloud_variable(variable_name=“present”, value=this)
」, but I cannot change the cloud variable.
leog20162
Scratcher
100+ posts

scratchclient - A scratch API wrapper for python

nikoniko0826

Last edited by leog20162 (Aug. 3, 2024 05:46:41)

leog20162
Scratcher
100+ posts

scratchclient - A scratch API wrapper for python

nikoniko0826 wrote:

I typed the code 「
import scratchconnect
import datetime
user = scratchconnect.ScratchConnect("nikoniko0826", "########")
project = user.connect_project(project_id=##########)
variables = project.connect_cloud_variables()
date=datetime.datetime.now()
this=datetime.date.today()
print(this)
set= variables.set_cloud_variable(variable_name="present", value=this)
」, but I cannot change the cloud variable.
bru, you can't set a variable to a text!!!!!!!!!!!!

Last edited by leog20162 (Aug. 3, 2024 05:47:48)

Walle2011
Scratcher
18 posts

scratchclient - A scratch API wrapper for python

Sometimes I get this error, I've done a bit of research but I can't seem to find what causes it, nor how to fix it, could someone explain to me who to fix it?

Exception in thread Thread-1 (_cloud_var_loop):
Traceback (most recent call last):
File “C:\Users\USER\AppData\Local\Programs\Python\Python313\Lib\threading.py”, line 1041, in _bootstrap_inner
self.run()
~~~~~~~~^^
File “C:\Users\USER\AppData\Local\Programs\Python\Python313\Lib\threading.py”, line 992, in run
self._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\USER\AppData\Local\Programs\Python\Python313\Lib\site-packages\scratchclient\CloudConnection.py”, line 221, in _cloud_var_loop
response = self._ws.recv()
File “C:\Users\USER\AppData\Local\Programs\Python\Python313\Lib\site-packages\scratchclient\Websocket.py”, line 236, in recv
data, opcode = self.recv_data()
~~~~~~~~~~~~~~^^
File “C:\Users\USER\AppData\Local\Programs\Python\Python313\Lib\site-packages\scratchclient\Websocket.py”, line 211, in recv_data
frame, err = Frame.decode_beginning(beginning_data)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
File “C:\Users\USER\AppData\Local\Programs\Python\Python313\Lib\site-packages\scratchclient\Websocket.py”, line 103, in decode_beginning
header = response
~~~~~~~~^^^
IndexError: index out of range

Powered by DjangoBB