Skip to content

Instantly share code, notes, and snippets.

@LordAro
Last active February 20, 2017 15:40
Show Gist options
  • Save LordAro/15242e42880aa8e6a9e21cf7fba0dd9d to your computer and use it in GitHub Desktop.
Save LordAro/15242e42880aa8e6a9e21cf7fba0dd9d to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
set -eu
# Expects API_KEY from env
API_BASE="https://ury.org.uk/api/v2/"
MIXCLOUD_BASE="https://www.mixcloud.com"
function api_call() {
local url="${API_BASE}$1?api_key=${API_KEY}"
echo "$(curl -s $url)"
}
args=$(echo $@ | tr ' ' '+')
SHOW_ID=$(api_call "show/searchmeta/${args}" | jq -r '.payload[0].show_id')
SEASON_ID=$(api_call "show/${SHOW_ID}/allseasons" | jq -r '.payload[-1].season_id')
MIXCLOUDS=$(api_call "season/${SEASON_ID}/alltimeslots" | \
jq -r ".payload[]
| select(.mixcloud_status | startswith(\"/\"))
| \"\(.title) - \(.first_time) - ${MIXCLOUD_BASE}\(.mixcloud_status)$\"")
echo $MIXCLOUDS | tr '$' '\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment