↖️ Show all posts

Make spotify useful for your favourite audio books and audio plays

It took me quite some nerves, because Spotify made a zero effort attempt linking audio books and plays.

get the source data from the API

JSONata

I always wondered how on earth I could put JSONata to use.

Lightweight query and transformation language for JSON data Inspired by the location path semantics of XPath 3.1 Sophisticated query expressions with minimal syntax Built in operators and functions for manipulating and combining data Create user-defined functions Format query results into any JSON output structure

JSONata Example for Sherlock Holmes (German)

{
    "items": $sort(items[$contains(name, 'Die Originale')].{
        "name": name,
        "uri": uri,
        "images": images,
        "spotifyUrl": external_urls.spotify,
        "case": $number($split($match(name, /[Folge|Fall] \d+/).match, " ")[-1])
    }, function($l, $r) {
        $l.case > $r.case
    }
    )
}

Code / Result

Here’s what I smashed together in two very simple NuxtJS apps.

Sherlock Holmes on Spotify

Bibi Blocksberg on Spotify


⬅️ Read previous Read next ➡️