Skip to main content

Overview

Content creators and music labels need to aggregate analytics from multiple streaming platforms — Spotify, YouTube, Apple Music, and others. Each platform has its own dashboard with different layouts and export formats. Manually logging in to each one and downloading reports is time-consuming and error-prone. Refrain automates the entire flow: log in, navigate to the analytics page, apply date filters, and export the data.

Example runbook

name: streaming-analytics-export
url: https://analytics.example-music.com/login
variables:
  - name: username
    source: secrets
  - name: password
    source: secrets
  - name: date_range
    source: fixed
    value: "last-30-days"
steps:
  - action: input
    selector: "#email"
    value: "{{ username }}"
  - action: input
    selector: "#password"
    value: "{{ password }}"
  - action: click
    selector: "#signIn"
  - action: wait
    selector: ".dashboard"
  - action: click
    selector: "[data-range='{{ date_range }}']"
  - action: wait
    timeout: 2000
  - action: download
    selector: ".export-csv-button"

Generate and execute

1

Generate the runbook

npx @refrainai/cli generate -- \
  --url https://analytics.example-music.com/login \
  --goal "Log in, select last 30 days, and download the analytics CSV" \
  --context ./context.md \
  --output ./streaming-report.yaml
2

Execute and download

npx @refrainai/cli execute -- \
  --runbook ./streaming-report.yaml \
  --secrets ./secrets.json \
  --output-dir ./reports
3

Merge multiple platforms

Run separate runbooks for each platform and use --merge-downloads to combine CSV exports:
npx @refrainai/cli execute -- \
  --runbook ./youtube-report.yaml \
  --output-dir ./reports \
  --merge-downloads

Why this works well

  • Multi-platform — Create one runbook per platform and run them all on a schedule.
  • Download handling — Automatically download and organize exported files.
  • Zero rerun cost — Monthly report collection runs without AI tokens.
  • Self-healing — Dashboard redesigns are handled automatically.

What’s next