Jump to content

Search Moby Games

Recommended Posts

This workflow allows you to search for games on Moby Games.

I'd like to add

  • image thumbnail
  • more game data for each result
  • alternative titles (foreign titles as defaults are US-centric)
  • more search types




Screen shot 2023-06-11 at 18.51.42.png

It is a bit early to be submitted to the Gallery.

I plan to add to it, but I feel there is a simpler way of me translating the Moby Games API JSON to Alfred JSON?

This is my first time using `jq`.

So I am here to learn.

Screen shot 2023-06-11 at 18.49.59.png

Edited by gingerbeardman
Link to comment

You should always prefer with input as argv over with input as {query}. You’re escaping too much so some characters won’t be sent correctly.

Also, you should likely be URL escaping the input text. Something like:


USER_INPUT="${1}" # This assumes with input as argv, ${1} replaces {query}
ESCAPED="$(osascript -l JavaScript -e "function run(argv) { return encodeURIComponent(argv[0]) }" "${USER_INPUT}")"



Long story short: your current approach will work now as you’re typing ASCII but it might break if a user types a special character.


Note that the ; is redundant. You only need that if you have two things on the same line. Unlike JavaScript, where it’s a matter of style, in shell pretty much no one ends all lines with a semicolon.


On 6/11/2023 at 6:51 PM, gingerbeardman said:

image thumbnail


To do that, small trick I use on Short Films:

  • Download the images to alfred_workflow_cache (be sure to create the folder: mkdir -p "${alfred_workflow_cache}")
  • Before every download, check if you already have it and use it if you do.
  • Once downloaded, check what’s the smaller of the two dimensions (width or height) then crop it to that to get a perfectly fitting square. This can all be done with sips which ships with macOS. I can get more specific later if you go that route.


On 6/11/2023 at 6:51 PM, gingerbeardman said:

I feel there is a simpler way of me translating the Moby Games API JSON to Alfred JSON?


If the code is working, I don’t really see anything wrong with your approach. There’s a “useless use of echo” and you could be using ' instead of " arounds some parts so you don’t need so many \, but that’s about it. Shell languages are far from the best way to deal with JSON, but considering that limitation you seem to be handling it well. I’d be more concerned with edge cases and the like. A more robust approach would be to use a language which natively supports JSON (note above how I called osascript -l JavaScript) to handle that part.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...