Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

1.8 KB
Raw Blame
import { sonarrCalendarEventSchema, sonarrMissingEpisodeSchema, SonarrIntegration } from "../sonarr/sonarr-integration";

/**
 * Sportarr (https://github.com/Sportarr/Sportarr) is a sports event manager
 * exposing a Sonarr-v3-compatible API: calendar, queue and wanted/missing
 * behave like Sonarr's with leagues surfacing as series and events as
 * episodes. Standalone events have no series. Validation, link branding,
 * web UI paths and the calendar badge differ from Sonarr.
 */
export class SportarrIntegration extends SonarrIntegration {
  protected override get calendarEventSchema() {
    return sonarrCalendarEventSchema.extend({ series: sonarrCalendarEventSchema.shape.series.nullable() });
  }

  protected override get missingEpisodeSchema() {
    return sonarrMissingEpisodeSchema.extend({ series: sonarrMissingEpisodeSchema.shape.series.nullable() });
  }

  protected override get calendarLinkName(): string {
    return "Sportarr";
  }

  protected override get calendarLinkLogo(): string {
    return "/images/apps/sportarr.svg";
  }

  // Sportarr seasons are years ("S2026/E43" overflows the badge), and
  // the calendar already shows the date, so the season adds nothing.
  protected override getCalendarBadgeContent(_seasonNumber: number, episodeNumber: number): string {
    return `E${episodeNumber}`;
  }

  // Sportarr shows a league at /leagues/{id}. It has no slug route.
  protected override getSeriesPath(series: { id?: number; titleSlug: string }): `/${string}` {
    return series.id === undefined ? "/leagues" : `/leagues/${series.id}`;
  }

  // Sportarr shows its queue and missing events on the activity page.
  protected override get missingFallbackPath(): `/${string}` {
    return "/activity";
  }

  protected override get queueFallbackPath(): `/${string}` {
    return "/activity";
  }
}