#!/bin/sh -e
#
# yt-chapters - get chapters with links of a video

yt-dlp --print-json --skip-download "$1" \
  | jq --raw-output '.chapters[] | "\(.start_time) \(.title)"' \
  | sed 's|\([0-9]*\)\.[0-9]* \(.*\)|[\2]('"$1"'?t=\1)|' | tr '\n' ' '
