fv1-programs icon indicating copy to clipboard operation
fv1-programs copied to clipboard

programs.json

Open eh2k opened this issue 4 years ago • 4 comments

Hello,

I'm the author of https://github.com/eh2k/fv1-emu. I'm thinking about to integrate your great collection of fv1-programs into the VCV-Rack Module, so the user can get/use the programs from https://mstratman.github.io/fv1-programs/ without using the browser.

The programs.js has exactly the data I need (category, controls etc).

Unfortunately the file is a JavaScript and it cannot be directly used in the C++ environment.

If you could provide a "programs.json" or change the programs.js to json, it would make the integration easier.

eh2k avatar Jun 05 '20 09:06 eh2k

Hi. I originally had this file as a JSON file but it was too inconvenient to work with, since it's primarily hand-edited. I switched it to ES6 to avoid worrying about quoting and comma rules.

If you write a script to ...

  1. quote all the object keys, and
  2. clean up stray trailing commas, and
  3. convert multi-line backtick quoted strings to single line double quotes,

...it should validate as JSON. Assuming it does, I can commit to ensuring never to add other content that won't work for json (i.e. not take advantage of other ES6 features)

That's outside the scope of what I'm going to do for this project though.

That is a really cool project, by the way. I'm looking forward to trying it out!

mstratman avatar Jun 05 '20 14:06 mstratman

By the way, this should be quick and easy with a little ES6 cli program, but I'm fighting with babel right now and it's not working. I'll give it another pass soon. Once put together, though, it'd just be a couple line script.

mstratman avatar Jun 06 '20 04:06 mstratman

Hi, thank you for your hint. I have found a nice solution right now. I'm using a github action cron pipeline, for fetching your repository. Here is the nodejs script:

https://github.com/eh2k/fv1-emu/blob/fv1-programs/fetch_programs.js

The script does:

  1. Executing your programs.js with 'eval'.
  2. Filter out program entries without "spn"-download (maybe I will implement other file types later)
  3. Downloading the spn-files and adding as base64 content
  4. Save programs.json with the spn-file-contents.
  5. gziping the programs.json

At the end there is a "programs.json.gz" with a size of 187KB containing 162 programs.

https://github.com/eh2k/fv1-emu/tree/gh-pages

PS: I was thinking, if you wouldn't mind, adding something like this into your build-script - so I could fetch the json directly from "https://mstratman.github.io/fv1-programs/programs.json":

var s = await fetch("https://raw.githubusercontent.com/mstratman/fv1-programs/master/programs.js");
eval(s.replace("export default", "var programs = "));
fs.writeFile('programs.json', JSON.stringify(programs, null, "\t"), function (err) {});

eh2k avatar Jun 06 '20 12:06 eh2k

I was thinking, if you wouldn't mind, adding something like this into your build-script - so I could fetch the json directly from "https://mstratman.github.io/fv1-programs/programs.json":

That's a really good idea. Reopening since that would solve both both projects well.

mstratman avatar Jun 08 '20 15:06 mstratman