> ## Documentation Index
> Fetch the complete documentation index at: https://docs.therefrain.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Streaming & Content Reports

> Collect play counts, royalties, and analytics from content platforms into a single export.

## 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

```yaml theme={null}
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

<Steps>
  <Step title="Generate the runbook">
    ```bash theme={null}
    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
    ```
  </Step>

  <Step title="Execute and download">
    ```bash theme={null}
    npx @refrainai/cli execute -- \
      --runbook ./streaming-report.yaml \
      --secrets ./secrets.json \
      --output-dir ./reports
    ```
  </Step>

  <Step title="Merge multiple platforms">
    Run separate runbooks for each platform and use `--merge-downloads` to combine CSV exports:

    ```bash theme={null}
    npx @refrainai/cli execute -- \
      --runbook ./youtube-report.yaml \
      --output-dir ./reports \
      --merge-downloads
    ```
  </Step>
</Steps>

## 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

<CardGroup cols={2}>
  <Card title="Execute a runbook" icon="play" href="/guides/execute-runbook">
    Learn about downloads and file exports.
  </Card>

  <Card title="Variables and secrets" icon="key" href="/guides/variables-and-secrets">
    Manage credentials for multiple platforms.
  </Card>
</CardGroup>
