Discuss Scratch

ScratchcatandGobo
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

Is there any ways to check if a user does or does not exist?

Yeah, but at least we've learned something today… that every moment of our life should be lived to the fullest because it can be very long or very short, my friend. - Gumball
I felt like I wanted to develop games on here, so I won't leave! (for now)
(last edited 2/8/24)





























infintyrussia
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchcatandGobo wrote:

Is there any ways to check if a user does or does not exist?
Try this:
https://api.scratch.mit.edu/accounts/checkusername/USERNAME_HERE


ScratchcatandGobo
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

infintyrussia wrote:

ScratchcatandGobo wrote:

Is there any ways to check if a user does or does not exist?
Try this:
https://api.scratch.mit.edu/accounts/checkusername/USERNAME_HERE
nvm, maybe

Last edited by ScratchcatandGobo (April 28, 2024 20:48:43)


Yeah, but at least we've learned something today… that every moment of our life should be lived to the fullest because it can be very long or very short, my friend. - Gumball
I felt like I wanted to develop games on here, so I won't leave! (for now)
(last edited 2/8/24)





























AwesomePeopleOutTher
Scratcher
22 posts

scratchattach - A Scratch API wrapper (Python)

Can I look up users with scratchattach based on their id. What I want to do is generate a random id and then find the user data correlating to the id.

AwesomePeopleOutTher
TheCommCraft
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

AwesomePeopleOutTher wrote:

(#2425)
Can I look up users with scratchattach based on their id. What I want to do is generate a random id and then find the user data correlating to the id.
It's not possible, the scratch api doesn't allow it

Random Project

spamton.gif





























DUNGEON_EXPLORATION_03_02_23_01
COMPILED VERSION FOR HIGHER SPEED
davidtheplatform
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

AwesomePeopleOutTher wrote:

Can I look up users with scratchattach based on their id. What I want to do is generate a random id and then find the user data correlating to the id.
You can use SUI

Generation 4: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.
Sid72020123
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

davidtheplatform wrote:

AwesomePeopleOutTher wrote:

Can I look up users with scratchattach based on their id. What I want to do is generate a random id and then find the user data correlating to the id.
You can use SUI

You can use the “/random” endpoint of the SUI API instead of generating a random ID and then getting the user. But the “/random” endpoint is very slow. So don't spam it.
Sometimes, the username returned may be deleted because the API doesn't delete the data of deleted usernames.

Sid72020123
AwesomePeopleOutTher
Scratcher
22 posts

scratchattach - A Scratch API wrapper (Python)

How do I reply to a studio comment?

AwesomePeopleOutTher
Him_is_bob
Scratcher
71 posts

scratchattach - A Scratch API wrapper (Python)

How do scratch3.Project objects work? and how can i get ids

when green flag clicked
if <cool scratcher :: sensing> then{
tell (username) [In a remaster race Go check out the original https://scratch.mit.edu/projects/644148324/] :: looks


} elif <uncool::sensing>{
tell (username) [Looking at my projects will make you cooler.....] :: looks
} :: control
Im sorry i had a bigger evil kumquat but it got eaten by a good signature :: #FFA500


MonkeyBean2
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

Him_is_bob wrote:

If I wanted to get the full project data sprites costumes everything how would I download? Also for uploading. I am building a scratch android app and these are crucial features

Here's my project download script:
import requests, json
from zipfile import ZipFile
from os import path
def download(id, destination=''):
    def getProjectJson(id):
        url = "https://projects.scratch.mit.edu/" + id
        return requests.get(url, allow_redirects=True).content
    def getAset(md5ext):
        url = "https://assets.scratch.mit.edu/internalapi/asset/"+md5ext+"/get/"
        response = requests.get(url, allow_redirects=True).content
        return response
    def packageZip(id, mainJson, assets):
        dest = destination
        if dest == '' or path.isdir(dest):
           dest += f'{id}.sb3'
        with ZipFile(dest, 'w') as zip:
            zip.writestr("project.json", mainJson)
            for asset in assets:
                # print("packaging "+asset['name']+"...")
                zip.writestr(asset['name'], asset['data'])
    def download_whole_project(id):
        print(f"downloading  {id}...")
        url = f"https://projects.scratch.mit.edu/{id}"
        mainJson = requests.get(url, allow_redirects=True).content
        assets = getAsets(json.loads(str(mainJson.decode())))
        print("packaging zip...")
        packageZip(id, mainJson, assets)
    def getAsets(mainJson):
        assets = []
        urls = []
        targets = mainJson['targets']
        for target in targets:
            costumes = target['costumes']
            sounds = target['sounds']
            for costume in costumes:
                urls.append(costume['md5ext'])
            for sound in sounds:
                urls.append(sound['md5ext'])
        urls = list(set(urls))
        print("getting assets...")
        for url in urls:
            print(url)
            assets.append({"data": getAset(url), "name": url})
        return assets
    download_whole_project(id)

Last edited by MonkeyBean2 (April 30, 2024 18:56:26)



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



scratchGui.timeTravel.year = '2020'
SHARKEE_7
Scratcher
22 posts

scratchattach - A Scratch API wrapper (Python)

Thanks so much for practically saving my life. Amazing API!

——-7——-
mehonje
Scratcher
5 posts

scratchattach - A Scratch API wrapper (Python)

I can't even get scratchattach to import. I used the pip install scratchattach to install it, but when I try to import it, it says

PS C:\Users\admin\Desktop\python_work> & CUsers/admin/AppData/Local/Microsoft/WindowsApps/python3.12.exe cUsers/admin/Desktop/python_work/scratchattach_test_1
Traceback (most recent call last):
File “c:\Users\admin\Desktop\python_work\scratchattach_test_1”, line 1, in <module>
import scratchattach as scratch3
ModuleNotFoundError: No module named ‘scratchattach’
PS C:\Users\admin\Desktop\python_work>

Am I doing something wrong? I've been on every Github, Replit, and scratch pages I could find about scratchattach, and I couldn't find anything wrong with my code. All it is is

import scratchattach as scratch3

Please help!
MonkeyBean2
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

-ProXeeI wrote:

It's so slow
user.is_following(“scratcher”)
user.is_followed_by(“scratcher”)
It's going to take a moment if it's requesting the API.


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



scratchGui.timeTravel.year = '2020'
fiosjeofo
Scratcher
10 posts

scratchattach - A Scratch API wrapper (Python)

-Twirlblast- wrote:

MineCodr wrote:

How do I make this get back the number of favs on a project?
This is what I have so far:
import scratchattach as scratch3

session = scratch3.login("MineCodr", "1234567 <— #lol this isn’t my real password obviously")
conn = session.connect_cloud(project_id="706531701")

client = scratch3.CloudRequests(conn) #optional argument: ignore_exceptions=True

@client.request
def ping():
print("Ping request received")
return "project.favorates"


client.run()
It's not favorates, it's favourites
Maybe that's why you code doesn't work

also, you have got it in speech marks in the line that says return “project.favorates” that means that when ping() runs it will output the text “project.favorates”, not the actual number of favourites

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

scratchattach - A Scratch API wrapper (Python)

what hosting does everyone use? i use bot-hosting.net, but it's annoying to keep adding coins.

Last edited by fiosjeofo (May 1, 2024 11:12:52)


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

scratchattach - A Scratch API wrapper (Python)

mehonje wrote:

I can't even get scratchattach to import. I used the pip install scratchattach to install it, but when I try to import it, it says

PS C:\Users\admin\Desktop\python_work> & CUsers/admin/AppData/Local/Microsoft/WindowsApps/python3.12.exe cUsers/admin/Desktop/python_work/scratchattach_test_1
Traceback (most recent call last):
File “c:\Users\admin\Desktop\python_work\scratchattach_test_1”, line 1, in <module>
import scratchattach as scratch3
ModuleNotFoundError: No module named ‘scratchattach’
PS C:\Users\admin\Desktop\python_work>

Am I doing something wrong? I've been on every Github, Replit, and scratch pages I could find about scratchattach, and I couldn't find anything wrong with my code. All it is is

import scratchattach as scratch3

Please help!
what is your code? (don't share your sessionid/password)

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

scratchattach - A Scratch API wrapper (Python)

fiosjeofo wrote:

mehonje wrote:

I can't even get scratchattach to import. I used the pip install scratchattach to install it, but when I try to import it, it says

PS C:\Users\admin\Desktop\python_work> & CUsers/admin/AppData/Local/Microsoft/WindowsApps/python3.12.exe cUsers/admin/Desktop/python_work/scratchattach_test_1
Traceback (most recent call last):
File “c:\Users\admin\Desktop\python_work\scratchattach_test_1”, line 1, in <module>
import scratchattach as scratch3
ModuleNotFoundError: No module named ‘scratchattach’
PS C:\Users\admin\Desktop\python_work>

Am I doing something wrong? I've been on every Github, Replit, and scratch pages I could find about scratchattach, and I couldn't find anything wrong with my code. All it is is

import scratchattach as scratch3

Please help!
what is your code? (don't share your sessionid/password)
its an issue i ran into with vscode. you have to install it through the terminal my using pip install scratchattatch

when green flag clicked
if <cool scratcher :: sensing> then{
tell (username) [In a remaster race Go check out the original https://scratch.mit.edu/projects/644148324/] :: looks


} elif <uncool::sensing>{
tell (username) [Looking at my projects will make you cooler.....] :: looks
} :: control
Im sorry i had a bigger evil kumquat but it got eaten by a good signature :: #FFA500


TheCommCraft
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

fiosjeofo wrote:

(#2436)
what hosting does everyone use? i use bot-hosting.net, but it's annoying to keep adding coins.
https://scratch.mit.edu/discuss/topic/753178

Random Project

spamton.gif





























DUNGEON_EXPLORATION_03_02_23_01
COMPILED VERSION FOR HIGHER SPEED
MysticalSk1ttle
Scratcher
8 posts

scratchattach - A Scratch API wrapper (Python)

is it possible to automatically comment? I'm trying to inform all of the competitiors in my contest that the results are out. I also need to do the same with the prize givers because there's 89 of them

when green flag clicked
broadcast [I'm epic v]
when I receive [ I'm epic v] 
ask [a random person," Am I Epic?"] and wait
if <(answer) = [yes]> then
switch costume to [happy v]
say [I know I am]
think [I'm glad he/she was an honest person]
else
if <(answer) = [no]> then
switch costume to [angry v]
say [How Dare You Lie To My Face!]
think [What A Jerk, Lying To My Face Like That]
nexoalex
Scratcher
77 posts

scratchattach - A Scratch API wrapper (Python)

mehonje wrote:

I can't even get scratchattach to import. I used the pip install scratchattach to install it, but when I try to import it, it says

PS C:\Users\admin\Desktop\python_work> & CUsers/admin/AppData/Local/Microsoft/WindowsApps/python3.12.exe cUsers/admin/Desktop/python_work/scratchattach_test_1
Traceback (most recent call last):
File “c:\Users\admin\Desktop\python_work\scratchattach_test_1”, line 1, in <module>
import scratchattach as scratch3
ModuleNotFoundError: No module named ‘scratchattach’
PS C:\Users\admin\Desktop\python_work>

Am I doing something wrong? I've been on every Github, Replit, and scratch pages I could find about scratchattach, and I couldn't find anything wrong with my code. All it is is

import scratchattach as scratch3

Please help!
bro I just downloaded the source code at the GitHub and extracted the zip then ran pip install scratchattach in command prompt or “terminal” tell me what os you have please so I can help further

Powered by DjangoBB