scratchattach icon indicating copy to clipboard operation
scratchattach copied to clipboard

How do I upload projects using Scratchattach?

Open NumbersTada opened this issue 1 year ago • 14 comments

can you give me some help?

NumbersTada avatar Oct 29 '23 12:10 NumbersTada

You can use

project = session.connect_project("PROJECTID")
project.set_json(json_data)

to change the project JSON of a project.

TimMcCool avatar Oct 29 '23 12:10 TimMcCool

That worked for an already existing project, but how do I create a new project?

NumbersTada avatar Oct 29 '23 12:10 NumbersTada

You can't create new projects with scratchattach

TimMcCool avatar Oct 29 '23 14:10 TimMcCool

OK

NumbersTada avatar Oct 30 '23 15:10 NumbersTada

Also, is it possible to fetch all projects of an user at once?

NumbersTada avatar Oct 30 '23 15:10 NumbersTada

user.projects(limit=None, offset=0) -> this returns all the shared projects of a user as scratch3.Project objects

RC9910-Scratch avatar Oct 30 '23 18:10 RC9910-Scratch

That only returns the first 20 projects

NumbersTada avatar Oct 31 '23 13:10 NumbersTada

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

gamecraft312 avatar Nov 24 '23 15:11 gamecraft312

You can't create new projects with scratchattach

will this ever happen?

Leaderofepic134 avatar Dec 28 '23 19:12 Leaderofepic134

You can't create new projects with scratchattach

will this ever happen?

Maybe

TimMcCool avatar Feb 27 '24 19:02 TimMcCool

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.

Waakul avatar Jun 20 '24 14:06 Waakul

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.

Waakul avatar Jun 20 '24 14:06 Waakul

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"])

TheCommCraft avatar Jun 20 '24 18:06 TheCommCraft

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.

namtacs avatar Jun 21 '24 05:06 namtacs

This is implemented in scratchattach 2.0 (will be released next week). #242

TimMcCool avatar Sep 28 '24 11:09 TimMcCool