Skip to content

GSE-CCL/scratch-convert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scratch-convert

Converts Scratch 2 to Scratch 3 JSON representations using LLK/scratch-vm.

Setup

  1. Make sure you've installed Node.js and NPM.
  2. Navigate the terminal to the downloaded repository.
  3. Run npm install.
  4. You should be all set to run the code as described below.

Usage

Usage: node convert.js [options]

  • -v, --verbose Verbose messaging.
  • -h, --help Display this usage guide.
  • -u, --unified Whether to save SB3 projects to a single unified directory. If not set, replicates original directory structure under the output root.
  • -d, --dest string Destination root directory for output files.
  • --src file ... List of directories and files to convert from SB2 to SB3. Directories will always be followed recursively.

Note that you'll always see a lot of errors as a result of running the headless Scratch VM with minimal features enabled (no audio renderer, etc.).

Examples

Convert all projects in directory SRC, saving new ones to root directory DEST, preserving directory structures recursively:

node convert.js -d DEST SRC

Convert projects A, B, C, and those in the directory SRC, to root directory DEST, without preserving directory structures:

node convert.js -ud DEST A B C SRC

Convert server

To use this code as a server to convert one project at a time, run node app.js.

Then you can POST to /convert with your Scratch 2 project JSON as the only data, with header application/json.

You'll receive the Scratch 3 JSON in return.

As a Python example:

import json
import requests

with open("test.json") as f:
    sb2 = json.load(f)

r = requests.post("http://localhost:3000/convert", json=sb2)
print(r.text)

About

Converts Scratch 2 to Scratch 3 JSON representations.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published