AviatoAviato
DeveloperPlugins

Artwork Search Plugins

How a plugin searches external sources for artwork (posters, covers, backdrops, thumbnails) and returns ranked candidates for library items.

An artwork search plugin queries one or more external sources — poster databases, music services, book stores, or any other artwork provider — and returns a ranked list of image candidates for a given library item. Aviato presents those candidates in the admin UI so a user can pick a preferred image, or automatically selects the highest-ranked one during ingestion.

Any external API that serves artwork can be wrapped as an artwork-search plugin. A movie or TV plugin might query a poster database; a music plugin might query a cover art archive; a books plugin might query an open metadata service.

When to use this versus a hook

SituationUse
You want to fetch and store a specific known artwork URLa hook on pipeline.index.afterProcess
You want to offer the user a list of candidates from an external servicean artwork search plugin
Your source requires searching by title, identifiers, or bothan artwork search plugin

Declaring the capability

Add artwork-search to the capabilities array in plugin.json. The mediaTypes field scopes your plugin to the library types where it makes sense: a plugin that only knows about movies should list ["movies"]; one that handles all media can list every type or omit mediaTypes entirely.

{
  "id": "@aviato-media/posters",
  "name": "Posters",
  "version": "1.0.0",
  "description": "Fetches posters, backdrops, and thumbnails from external artwork databases",
  "author": "Aviato",
  "license": "MIT",
  "engine": "bun",
  "entry": "src/index.ts",
  "aviato": { "minVersion": "0.1.0" },

  "capabilities": ["artwork-search"],
  "mediaTypes": ["movies", "tv"],

  "configuration": [
    { "key": "apiKey", "label": "API Key", "input": "text", "required": true }
  ]
}

Wire protocol

The canonical types are defined in the plugin SDK as ArtworkSearchHandlers, ArtworkSearchRequest, and ArtworkSearchResult. What follows is a summary of the shapes the server and plugin agree on.

Request

The server calls artworkSearch.search with a description of the item it needs artwork for:

interface ArtworkSearchRequest {
  /** The library item's internal ID. */
  itemId: string
  /** Display title, useful for text-based search queries. */
  title: string
  /** Known external identifiers (for example `{ tmdbId: '123', imdbId: 'tt0000001' }`). */
  externalIds: Record<string, string>
  /** The media type of the item, for example `'movies'`, `'tv'`, `'music'`. */
  mediaType: string
  /** Which artwork roles are being requested, for example `['poster', 'backdrop', 'thumbnail']`. */
  roles: string[]
}

Use externalIds when your source supports lookup by a stable identifier — this avoids ambiguous title searches. Fall back to title when no relevant ID is present.

Response

Return an array of ArtworkSearchResult entries. The server merges results from all eligible plugins, so each entry identifies its role and relevance:

interface ArtworkSearchResult {
  /** Artwork role: `'poster'`, `'backdrop'`, `'thumbnail'`, `'cover'`, `'logo'`, etc. */
  role: string
  /** Publicly accessible URL for the full-resolution image. */
  url: string
  /** Optional thumbnail URL shown in the picker grid. Defaults to `url` when absent. */
  thumbnailUrl?: string
  /** Width in pixels, if known. */
  width?: number
  /** Height in pixels, if known. */
  height?: number
  /** ISO 639-1 language code of the text in the image, if any. */
  language?: string
  /**
   * Relative ranking within your plugin's results for this role.
   * The server uses this, combined with user preferences, to sort
   * the candidate list. Higher is preferred. Values need only be
   * consistent within a single response.
   */
  score?: number
}

Handler interface

The SDK exposes an ArtworkSearchHandlers interface; pass it under the artwork-search key when calling createPlugin:

import type { ArtworkSearchHandlers } from '@aviato-media/plugin-sdk'
import { createPlugin } from '@aviato-media/plugin-sdk'

const handlers: ArtworkSearchHandlers = {
  search: async ({ title, externalIds, roles }) => {
    const results: ArtworkSearchResult[] = []

    if (roles.includes('poster')) {
      const posters = await fetchPosters(externalIds.tmdbId ?? title)
      results.push(
        ...posters.map((p, i) => ({
          role: 'poster',
          url: p.fullUrl,
          thumbnailUrl: p.thumbUrl,
          width: p.width,
          height: p.height,
          language: p.iso_639_1,
          score: posters.length - i,
        })),
      )
    }

    if (roles.includes('backdrop')) {
      const backdrops = await fetchBackdrops(externalIds.tmdbId ?? title)
      results.push(
        ...backdrops.map((b, i) => ({
          role: 'backdrop',
          url: b.fullUrl,
          thumbnailUrl: b.thumbUrl,
          width: b.width,
          height: b.height,
          score: backdrops.length - i,
        })),
      )
    }

    return results
  },
}

createPlugin({ 'artwork-search': handlers })

The SDK wires the artworkSearch.search RPC method automatically. The server calls it once per eligible plugin whenever artwork candidates are needed: during ingestion, on user request, or during a manual refresh.

Roles

The role field identifies the artwork's intended use:

RoleTypical use
posterPortrait or square cover shown in grid and detail views.
backdropWide landscape background for detail pages.
thumbnailSmall square used in lists and episode cards.
coverFront cover for books, albums, and similar media.
logoTitle treatment or channel and studio logo.

Return only roles that were requested. An empty array is valid; the server falls back to other plugins or to whatever is already stored.

Rate limiting

Artwork APIs typically enforce per-key rate limits. Declare a rateLimit block in plugin.json to tell Aviato how to throttle calls so you do not exhaust your quota during a bulk ingestion run:

"rateLimit": {
  "maxConcurrency": 4,
  "requests": [
    { "max": 40, "window": "10s" }
  ]
}

See the rate-limit section of indexer.mdx for guidance on choosing values.

See also

On this page