JSON data from API output to Shortcuts (or textfile via scriptable)

Displaying the image was a bit of a puzzle for me.

I put them in the folder structure img/crest within Scriptable (using iCloud Drive), with the team identifier as the filename (I wanted to use the 3 letter abbreviations, but in at least one league there were two teams with the same abbreviation; identifiers should be unique though).

Then this code displays a logo:

const team = match.homeTeam
const image = Image.fromFile(`${FileManager.iCloud().documentsDirectory()}/img/crest/${team.id}.png`)
const cell = UITableCell.image(image)
cell.centerAligned()
row.addCell(cell)

Furthermore, I use JavaScript formatting for dates and times:

  • .toLocaleDateString('nl-NL', {day: 'numeric', month: 'long', year: 'numeric'})
  • .toLocaleTimeString('nl-NL', {hour: '2-digit', minute: '2-digit'})

PS: I later changed long into short (so all months are 3 letter abbreviations; looks better to me)

Hope this helps (the remaining code is a bit lousy; I’d rather not share that now).

I’ve been working on a shortcuts version, and selecting the team to report on.
It now works (a bit) but is not nearly as polished as your examples.

Will keep working on mine as well.

Did it in the new version of shortcuts, and MAN is that buggy!

1 Like

Made an iPhone specific layout, with a bit more info (competition) (but had to remove the logos):

1 Like

I’m trying to make a variation of this for Euro 2020 and want to use the national flags instead of club logos (I have already learned how to add flags via the U2 script on this forum).

Unfortunately, football-data.org uses proprietary three-letter-abbreviations for countries…

For now, I’m considering to use the top level country code from the website of a team to show the flag, but maybe I can do something smarter?

If they aren’t any of the standardised codes, which would of course be a very strange choice for a public API, then you would need to translate them either by pairing off the codes (dictionaries are your friend) or the country name.

Direct mapping aside, the country name might be enough to scrape from a web page to save you creating your own mapping.

1 Like

Looks like they are unfortunately not standardized; the very first team returned by the API is Germany, for which they use the TLA “GER”, while it’s “DEU” or “DE” in the list you shared.

But looking at some sample data on the web site, it does look like the country name is available; which means you could use the name to lookup the ISO code for the unicode icon. This matches to my second suggestion in my previous post of using the country name rather than the code.

I have a gist with the JSON for country and 2-digit ISO code. You could load that data to get the ISO code based on the country’s name.

1 Like

I missed your post because I was implementing my hack…

That works, but your solution is nicer!

PS: Which tool did you use in your screenshot to highlight multiple lines?

While it was a good exercise to add the flags, I think I still prefer the cleaner iPhone layout…

It’s an app called Annotable. I’ve found it the best image annotator on i*OS to date. In terms of less common features, it has obfuscation, smart text highlighting, spotlighting (what I used above), callouts, and you can zoom in for more accurate editing.

I frequently use it to edit my last screen shot by launching it via this URL from a widget (Launcher).

annotable://annotate?image=last_photo

It is free with an in-app purchases for some of the advanced features, and if you’re looking, chances are that they are the features you want.

I updated on an early release and I’m pretty sure that the pricing was on a 50% launch deal back then. I’m very happy with it, but the full unlock price might be a little high unless you annotate a lot of images.

Hope that helps.

1 Like

So I just had to implement that (mainly because I realized my hack used a lot more API calls and this API is rate-limited).

Thank you for providing that gist!

No problem. Glad it was of use.

I created a CSV version for speeding up (and standardising) some client system configurations I use at work, and created a JSON format at the same time from it, just in case I ever needed it. Then I just figured they might be useful for others and put them both in gists. Looks like I was right :sunglasses:

1 Like