scratchattach
scratchattach copied to clipboard
How do I upload projects using Scratchattach?
can you give me some help?
You can use
project = session.connect_project("PROJECTID")
project.set_json(json_data)
to change the project JSON of a project.
That worked for an already existing project, but how do I create a new project?
You can't create new projects with scratchattach
OK
Also, is it possible to fetch all projects of an user at once?
user.projects(limit=None, offset=0)
-> this returns all the shared projects of a user as scratch3.Project
objects
That only returns the first 20 projects
That worked for an already existing project, but how do I create a new project?
you can use: import webbrowser
webbrowser.open_new_tab(https://scratch.mit.edu/projects/editor/) #this will make the ID and generate a new project
You can't create new projects with scratchattach
will this ever happen?
You can't create new projects with scratchattach
will this ever happen?
Maybe
you can send a request to https://scratch.mit.edu/projects/editor/ . I'm not sure how to get its id tho. You'll have to a list of your project from an API and check the id of the latest one.
you could get the id using bs4 in "https://scratch.mit.edu/mystuff/" with all your cookies i believe, the link to it is in the a tag of the top most project. you could parse the id out of it.
You need to do a post request to https://projects.scratch.mit.edu/ and get "content-name" from the response.
Example(not guarranteed to work):
import requests
session = ... # Create your session here
response = requests.post("https://projects.scratch.mit.edu/", headers=session._headers, cookies=session._cookies)
project_id = int(response.json()["content-name"])
Look and discuss api here https://github.com/towerofnix/scratch-api-unofficial-docs/issues/37
Also, I am currently making a giant fork (for now private) that is a rework of scratchattach. Eventually, i will merge it (prob split). I can implement that easily.
This is implemented in scratchattach 2.0 (will be released next week). #242