---
name: Fetch Album Info
description: Search the web for album information and save a detailed info file.
version: 1
mode: agentic
triggers:
  - type: directory
inputs:
  artist_name:
    type: string
    description: Artist name
    autofill: entry_name
  album_name:
    type: string
    description: Album name
    autofill: entry_name
---

# Fetch Album Info

You are given an artist name and album name. Your job is to find comprehensive information about this album from the web.

## Process

1. **Search** for the album using `web_search` with queries like `"<artist> <album> wikipedia"`, `"<artist> <album> musicbrainz"`, `"<artist> <album> allmusic"`.
2. **Fetch** the most relevant pages using `web_fetch` to extract detailed information.
3. **Cross-reference** multiple sources to get the most accurate and complete data.
4. **Download** the front cover image and save it as `cover.{ext}` (matching the image format, e.g. `cover.jpg`) in the target directory. Overwrite if it already exists.
5. **Save** the result as an `album-info.md` file in the target directory (provided in Context).

## Information to collect

- **Artist** name (canonical/correct spelling)
- **Album** title (canonical/correct spelling)
- **Release year** (original release)
- **Genre(s)** and subgenres
- **Label** / record company
- **Tracklist** — for each track: number, title, duration. For multi-disc releases, organize by disc.
- **Total duration**
- **Front cover image URL** — find the highest quality cover art URL available (Wikipedia, MusicBrainz cover art archive)
- **Credits** — producer, engineer, notable musicians (if available)
- **Additional notes** — compilation info, remaster details, notable facts

## Output format

Write a markdown file named `album-info.md` in the **target directory** (from Context) with this structure:

```markdown
# Artist — Album Title

![Cover](url-to-cover-image)

| Field | Value |
|-------|-------|
| Artist | ... |
| Album | ... |
| Year | ... |
| Genre | ... |
| Label | ... |
| Duration | ... |

## Tracklist

### Disc 1
| # | Title | Duration |
|---|-------|----------|
| 1 | ... | 0:00 |

### Disc 2
...

## Credits
- Producer: ...
- ...

## Notes
...
```

If there is only one disc, omit the "Disc 1" heading and just use a flat tracklist.

## Cover art download

Once you have a cover image URL, download it to the target directory using curl:
```
curl -sL -o "<target_dir>/cover.<ext>" "<image_url>"
```
Use the correct extension based on the image format (jpg, png, etc.). Overwrite any existing file.
In the `album-info.md`, keep the original remote URL in the image tag: `![Cover](<original_url>)`.

## Important

- Prefer Wikipedia for context, genre classification, credits, and tracklist data.
- Use MusicBrainz / Cover Art Archive for high-quality cover image URLs and precise edition identification.
- Use AllMusic as an additional source for credits and reviews.
- If information conflicts between sources, prefer Wikipedia for metadata and MusicBrainz for tracklist data.
- Do NOT make up information. If something is not found, omit it.
