iMovie automate video creation from json?

We're trying to automate the process of creating an imovie video by pulling in json data from a list from each of the following subfolders.

So here are the FamilyGuy subfolders with their repeating content:

Peter / character.json image.jpg
Lois / character.json image.jpg
Stewie / character.json image.jpg

Peter/character.json:

{
  "name": "Peter Griffin", // imovie placeholder title spot #1
  "familyRole": "The Father", // imovie placeholder title spot #2
  "image": "image.jpg" // imovie placeholder image spot #1
}

Lois/character.json:

{
  "name": "Lois Griffin",
  "familyRole": "The Mother",
  "image": "image.jpg"
}

Stewie/character.json:

{
  "name": "Stewie Griffin",
  "familyRole": "The Baby",
  "image": "image.jpg"
},

With the first video created for Peter manually using data from the first json, we export it as Peter_Griffin.mp4. How can we automate this task so we can automatically create 2 more videos Lois_Griffin.mp4 and Stewie_Griffin.mp4 each video using it's respective character.json and image?

Visual Explanation:
Here is an image to help describe what we're trying to do programmatically/via an automatic workflow:

enter image description here

The static zones should not change, the other parts should be derived from the json data. So if we save and export the following video for Peter, how can we automatically have the videos for Lois/Stewie auto created/saved/exported as well? Is this something KeyboardMaestro can automate?

you can:
1- use names as variables,
2-move the mouse so it clicks and interacts with iMovie.

btw if you know Photoshop, you could also do something very similar, it also has a video timeline

Thank you hello. I am new to Keyboard Maestro and found the JSON part a bit complicated (getting values from a JSON file in a directory).
Here is a simpler example that will really help with understanding how KM works. Any idea how setup Keyboard Maestro to:

  1. Start from the root folder FamilyGuy
  2. Iterate over each available subfolder Peter/Lois/Stewie
  3. Open subfolder/character.json and grab values for "name" and "familyRole"
  4. Open TextEdit app, paste in the values for "name" so it says (Peter Griffin) on the first line, and "familyRole" so it says (The Father) on the second line. Save file as Peter_Griffin.rtf in subfolder.

Sorry for the newbie question. This tool seems very powerful, but a bit hard to grasp from the JSON file as a source while iterating over the subfolders and saving a new file in each subfolder based on the derived json values.

Note: the JSON you posted is invalid, you need to remove the comments:
// imovie placeholder title spot #1

in KM you can use read file from a folder,
grab JSON content from file
and also simulate keystrokes.

Here's a first step:

image

Thank you so much for your help hello. Grabbing JSON values and pasting them in TextEdit is trivial now after going through your JSON actions example. It works when we explicitly specify a subfolder "Read File to Variable "JSON"" with a Read File path of ~/Downloads/FamilyGuy/Peter/character.json. But to set "FamilyGuy" as a source folder and have KM go thru each subfolder Peter/Lois/Stewie I tried using the different "Each" actions available but they ask for a variable, not sure what to do there. I am trying to loop thru each subfolder to save Peter_Griffin.rtf/Lois_Griffin.rtf/Stewie_Griffin.rtf in their respective subfolder. Any idea how to do this?

try the For Each Path in Folder action

This is what it looks like so far:
20%20PM

But that workflow returns the following notifications:
31%20PM

Instead of alerting the other 2 character names, it only alert Peter Griffin followed by a notification error for each, not sure why. Any idea?

can you try:

Thanks for linking that thread, I figured out what was wrong. In Read File to Variable "JSON" the Read file was:

~/Desktop/FamilyGuy/%Variable%subfolder%/character.json

instead it should be:

%Variable%subfolder%/character.json

As the subfolder variable included the full path, not just the subfolder name.

Thank you so much for all your help, really appreciate it!

1 Like