discdbapi
    Preparing search index...

    Class DiscDBClient

    Index

    Constructors

    • Parameters

      • Optionaloptions: { origin?: string; userAgent?: string }

      Returns DiscDBClient

    Properties

    gql: Client

    Internal, typed GraphQL client that may be used to bypass wrapper logic or compose custom queries

    origin: string = DISCDB_ORIGIN
    userAgent: string = ...

    Methods

    • Returns a qualified image URL for a barcode representing a given UPC

      Parameters

      • code: string | number

        the UPC value

      • Optionaloptions: { label?: boolean; width?: number }

        options for creating the image

        • width: the width of the image
        • label: whether to show the number in the image (not recommended; may gets cropped out)

      Returns string

      URL to the barcode image

    • Parameters

      • slug: string

      Returns Promise<
          | Boxset
          | Pick<
              {
                  __typename: "Boxset";
                  id: number;
                  imageUrl: string
                  | null;
                  release: FieldsSelection<
                      Release
                      | null,
                      {
                          asin: boolean;
                          discs: {
                              __args: { order: { index: "ASC" }[] };
                              contentHash: boolean;
                              format: boolean;
                              globalDiscId: boolean;
                              index: boolean;
                              name: boolean;
                              slug: boolean;
                              titles: {
                                  __args: { order: { index: ... }[] };
                                  displaySize: boolean;
                                  duration: boolean;
                                  index: boolean;
                                  item: {
                                      chapters: {
                                          __args: { order: ... };
                                          index: boolean;
                                          title: boolean;
                                      };
                                      description: boolean;
                                      episode: boolean;
                                      season: boolean;
                                      title: boolean;
                                      type: boolean;
                                  };
                                  segmentMap: boolean;
                                  size: boolean;
                                  sourceFile: boolean;
                              };
                          };
                          imageUrl: boolean;
                          locale: boolean;
                          regionCode: boolean;
                          slug: boolean;
                          title: boolean;
                          upc: boolean;
                          year: boolean;
                      },
                  >;
                  releaseId: number;
                  slug: string
                  | null;
                  sortTitle: string | null;
                  title: string | null;
                  type: string;
              },
              "slug"
              | "title"
              | "imageUrl"
              | "type"
              | "release"
              | "sortTitle",
          >
          | undefined,
      >

    • Type Parameters

      • Selection extends BoxsetGenqlSelection = {
            imageUrl: true;
            release: { imageUrl: true; slug: true; title: true; year: true };
            slug: true;
            sortTitle: true;
            title: true;
            type: true;
        }

      Parameters

      Returns Promise<
          {
              boxsets: | Boxset[]
              | NonNullable<FieldsSelection<Boxset[] | null, NonNullable<Selection>>>;
              page: { cursor: string | null; hasMoreData: boolean } | undefined;
          },
      >

    • Using a precalculated global disc ID and/or content hash, find a unique disc with its nested releases and media items.

      Most discs in the database have a content hash, but the global ID is slightly easier to obtain due to its use in other tools.

      Parameters

      • values: { id: string } | { hash: string } | { hash: string; id: string }

        the ID and/or hash of the disc

      Returns Promise<ReverseMappedDisc>

      matching disc with releases

    • Returns a qualified image URL from a path. If only one dimension is provided, the other dimension will be resized automatically, maintaining the original aspect ratio.

      Parameters

      • path: string
      • Optionaloptions: { height?: number; width?: number }

      Returns string

    • Returns a matching media item (movies/series) with releases that contain a disc with the specified hash and details for the disc. There may be multiple releases and media items with the same disc. This method will only return the first media item, use getMediaItemsByDiscHashes to receive all results.

      Parameters

      • hash: string

        the disc hash (from hashDisc)

      Returns Promise<
          Pick<
              {
                  __typename: "MediaItem";
                  contentRating: string
                  | null;
                  dateAdded: any;
                  directors: string | null;
                  externalids: ExternalIds;
                  externalIdsId: number;
                  fullTitle: string | null;
                  genres: string | null;
                  id: number;
                  imageUrl: FieldsSelection<string | null, boolean>;
                  latestReleaseDate: any;
                  mediaItemGroups: MediaItemGroup[];
                  plot: string | null;
                  releaseDate: any;
                  releases: Pick<
                      {
                          __typename: "Release";
                          asin: FieldsSelection<string | null, boolean>;
                          backImageUrl: string | null;
                          boxset: Boxset | null;
                          contributors: Contributor[];
                          dateAdded: any;
                          discs: Pick<
                              {
                                  __typename: "ReleaseDisc";
                                  contentHash: FieldsSelection<(...) | (...), boolean>;
                                  disc: Disc | null;
                                  discId: number;
                                  format: FieldsSelection<(...) | (...), boolean>;
                                  globalDiscId: FieldsSelection<(...) | (...), boolean>;
                                  id: number;
                                  index: number;
                                  name: FieldsSelection<(...) | (...), boolean>;
                                  release: Release | null;
                                  releaseId: number;
                                  slug: FieldsSelection<(...) | (...), boolean>;
                                  titles: Pick<(...), (...)>[];
                              },
                              | "slug"
                              | "index"
                              | "name"
                              | "format"
                              | "contentHash"
                              | "globalDiscId"
                              | "titles",
                          >[];
                          fullTitle: string;
                          id: number;
                          imageUrl: FieldsSelection<string | null, boolean>;
                          isbn: string | null;
                          locale: FieldsSelection<string | null, boolean>;
                          mediaItem: MediaItem | null;
                          regionCode: FieldsSelection<string | null, boolean>;
                          releaseDate: any;
                          releaseGroups: ReleaseGroup[];
                          slug: FieldsSelection<string | null, boolean>;
                          title: FieldsSelection<string | null, boolean>;
                          type: string;
                          upc: FieldsSelection<string | null, boolean>;
                          year: number;
                      },
                      | "slug"
                      | "locale"
                      | "regionCode"
                      | "year"
                      | "title"
                      | "imageUrl"
                      | "discs"
                      | "upc"
                      | "asin",
                  >[];
                  runtime: string
                  | null;
                  runtimeMinutes: number;
                  slug: FieldsSelection<string | null, boolean>;
                  sortTitle: string | null;
                  stars: string | null;
                  tagline: string | null;
                  title: FieldsSelection<string | null, boolean>;
                  type: FieldsSelection<string | null, boolean>;
                  writers: string | null;
                  year: number;
              },
              | "slug"
              | "year"
              | "title"
              | "imageUrl"
              | "type"
              | "externalids"
              | "releases",
          >,
      >

      matching media item

    • Fetch a media item by its external database IDs. If there are multiple results (e.g you provided IDs for items that are not the same), only the first result will be returned.

      Database items are created with their TMDB association, so every item should have one. If you only have an IMDb or TVDB ID, you may find more success if you first consult TMDB:

      Parameters

      • ids: { imdbId?: string; tmdbId?: string; tvdbId?: string }

        one or multiple IDs with which to try to identify the item.

      Returns Promise<
          Pick<
              {
                  __typename: "MediaItem";
                  contentRating: string
                  | null;
                  dateAdded: any;
                  directors: string | null;
                  externalids: ExternalIds;
                  externalIdsId: number;
                  fullTitle: string | null;
                  genres: string | null;
                  id: number;
                  imageUrl: FieldsSelection<string | null, boolean>;
                  latestReleaseDate: any;
                  mediaItemGroups: MediaItemGroup[];
                  plot: string | null;
                  releaseDate: any;
                  releases: Pick<
                      {
                          __typename: "Release";
                          asin: FieldsSelection<string | null, boolean>;
                          backImageUrl: string | null;
                          boxset: Boxset | null;
                          contributors: Contributor[];
                          dateAdded: any;
                          discs: Pick<
                              {
                                  __typename: "ReleaseDisc";
                                  contentHash: FieldsSelection<(...) | (...), boolean>;
                                  disc: Disc | null;
                                  discId: number;
                                  format: FieldsSelection<(...) | (...), boolean>;
                                  globalDiscId: FieldsSelection<(...) | (...), boolean>;
                                  id: number;
                                  index: number;
                                  name: FieldsSelection<(...) | (...), boolean>;
                                  release: Release | null;
                                  releaseId: number;
                                  slug: FieldsSelection<(...) | (...), boolean>;
                                  titles: Pick<(...), (...)>[];
                              },
                              | "slug"
                              | "index"
                              | "name"
                              | "format"
                              | "contentHash"
                              | "globalDiscId"
                              | "titles",
                          >[];
                          fullTitle: string;
                          id: number;
                          imageUrl: FieldsSelection<string | null, boolean>;
                          isbn: string | null;
                          locale: FieldsSelection<string | null, boolean>;
                          mediaItem: MediaItem | null;
                          regionCode: FieldsSelection<string | null, boolean>;
                          releaseDate: any;
                          releaseGroups: ReleaseGroup[];
                          slug: FieldsSelection<string | null, boolean>;
                          title: FieldsSelection<string | null, boolean>;
                          type: string;
                          upc: FieldsSelection<string | null, boolean>;
                          year: number;
                      },
                      | "slug"
                      | "locale"
                      | "regionCode"
                      | "year"
                      | "title"
                      | "imageUrl"
                      | "discs"
                      | "upc"
                      | "asin",
                  >[];
                  runtime: string
                  | null;
                  runtimeMinutes: number;
                  slug: FieldsSelection<string | null, boolean>;
                  sortTitle: string | null;
                  stars: string | null;
                  tagline: string | null;
                  title: FieldsSelection<string | null, boolean>;
                  type: FieldsSelection<string | null, boolean>;
                  writers: string | null;
                  year: number;
              },
              | "slug"
              | "year"
              | "title"
              | "imageUrl"
              | "type"
              | "externalids"
              | "releases",
          >,
      >

      a matching media item

    • Returns multiple matching media items (movies/series) with releases that contain a disc with the specified hash and details for the disc. There may be multiple releases and media items with the same disc.

      Hashes with no matches will still be in the resulting record, but with an empty array.

      Parameters

      • hashes: string[]

        the disc hashes (from hashDisc)

      Returns Promise<
          Record<
              string,
              Pick<
                  {
                      __typename: "MediaItem";
                      contentRating: string
                      | null;
                      dateAdded: any;
                      directors: string | null;
                      externalids: ExternalIds;
                      externalIdsId: number;
                      fullTitle: string | null;
                      genres: string | null;
                      id: number;
                      imageUrl: FieldsSelection<string | null, boolean>;
                      latestReleaseDate: any;
                      mediaItemGroups: MediaItemGroup[];
                      plot: string | null;
                      releaseDate: any;
                      releases: Pick<
                          {
                              __typename: "Release";
                              asin: FieldsSelection<string | null, boolean>;
                              backImageUrl: string | null;
                              boxset: Boxset | null;
                              contributors: Contributor[];
                              dateAdded: any;
                              discs: Pick<
                                  {
                                      __typename: ...;
                                      contentHash: ...;
                                      disc: ...;
                                      discId: ...;
                                      format: ...;
                                      globalDiscId: ...;
                                      id: ...;
                                      index: ...;
                                      name: ...;
                                      release: ...;
                                      releaseId: ...;
                                      slug: ...;
                                      titles: ...;
                                  },
                                  (...)
                                  | (...)
                                  | (...)
                                  | (...)
                                  | (...)
                                  | (...)
                                  | (...),
                              >[];
                              fullTitle: string;
                              id: number;
                              imageUrl: FieldsSelection<string | null, boolean>;
                              isbn: string | null;
                              locale: FieldsSelection<string | null, boolean>;
                              mediaItem: MediaItem | null;
                              regionCode: FieldsSelection<string | null, boolean>;
                              releaseDate: any;
                              releaseGroups: ReleaseGroup[];
                              slug: FieldsSelection<string | null, boolean>;
                              title: FieldsSelection<string | null, boolean>;
                              type: string;
                              upc: FieldsSelection<string | null, boolean>;
                              year: number;
                          },
                          | "slug"
                          | "locale"
                          | "regionCode"
                          | "year"
                          | "title"
                          | "imageUrl"
                          | "discs"
                          | "upc"
                          | "asin",
                      >[];
                      runtime: string
                      | null;
                      runtimeMinutes: number;
                      slug: FieldsSelection<string | null, boolean>;
                      sortTitle: string | null;
                      stars: string | null;
                      tagline: string | null;
                      title: FieldsSelection<string | null, boolean>;
                      type: FieldsSelection<string | null, boolean>;
                      writers: string | null;
                      year: number;
                  },
                  | "slug"
                  | "year"
                  | "title"
                  | "imageUrl"
                  | "type"
                  | "externalids"
                  | "releases",
              >[],
          >,
      >

      a mapping of disc hashes to media item arrays

    • Get all media items which are "tagged" with a specific group. This is used by TheDiscDB to identify cast, crew, genres, and studios.

      Parameters

      Returns Promise<
          {
              mediaItems: | MediaItem[]
              | Pick<
                  {
                      __typename: "MediaItem";
                      contentRating: string
                      | null;
                      dateAdded: any;
                      directors: string | null;
                      externalids: ExternalIds;
                      externalIdsId: number;
                      fullTitle: string | null;
                      genres: string | null;
                      id: number;
                      imageUrl: string | null;
                      latestReleaseDate: any;
                      mediaItemGroups: Pick<
                          {
                              __typename: "MediaItemGroup";
                              group: FieldsSelection<
                                  (...)
                                  | (...),
                                  { imageUrl: ...; name: ...; on_Group: ...; slug: ... },
                              >;
                              groupId: number;
                              id: number;
                              isFeatured: boolean;
                              mediaItem: MediaItem | null;
                              mediaItemId: number;
                              role: string | null;
                          },
                          "role"
                          | "on_MediaItemGroup"
                          | "group",
                      >[];
                      plot: string | null;
                      releaseDate: any;
                      releases: Pick<
                          {
                              __typename: "Release";
                              asin: string
                              | null;
                              backImageUrl: string | null;
                              boxset: Boxset | null;
                              contributors: Contributor[];
                              dateAdded: any;
                              discs: Pick<(...), (...)>[];
                              fullTitle: string;
                              id: number;
                              imageUrl: string | null;
                              isbn: string | null;
                              locale: string | null;
                              mediaItem: MediaItem | null;
                              regionCode: string | null;
                              releaseDate: any;
                              releaseGroups: ReleaseGroup[];
                              slug: string | null;
                              title: string | null;
                              type: string;
                              upc: string | null;
                              year: number;
                          },
                          "slug"
                          | "locale"
                          | "year"
                          | "title"
                          | "discs"
                          | "on_Release",
                      >[];
                      runtime: string | null;
                      runtimeMinutes: number;
                      slug: string | null;
                      sortTitle: string | null;
                      stars: string | null;
                      tagline: string | null;
                      title: string | null;
                      type: string | null;
                      writers: string | null;
                      year: number;
                  },
                  | "slug"
                  | "year"
                  | "title"
                  | "imageUrl"
                  | "type"
                  | "releases"
                  | "mediaItemGroups"
                  | "on_MediaItem",
              >[];
              page: { cursor: string | null; hasMoreData: boolean }
              | undefined;
          },
      >

      media items and page info

      await discdb.getMediaItemsByGroup("disney", MediaItemGroupRole.Company);
      
      await discdb.getMediaItemsByGroup(
      "adam-scott",
      MediaItemGroupRole.Actor,
      { query: { type: MediaItemType.Series } },
      );
    • Fetch a release by its URL slugs, useful for resolving a user-provided link.

      Parameters

      • mediaItemSlug: string

        the slug for the media item as a whole on thediscdb.com

      • slug: string

        the slug for just the release on thediscdb.com

      Returns Promise<
          Pick<
              {
                  __typename: "Release";
                  asin: FieldsSelection<string | null, boolean>;
                  backImageUrl: string | null;
                  boxset: Boxset | null;
                  contributors: Contributor[];
                  dateAdded: any;
                  discs: Pick<
                      {
                          __typename: "ReleaseDisc";
                          contentHash: FieldsSelection<string | null, boolean>;
                          disc: Disc | null;
                          discId: number;
                          format: FieldsSelection<string | null, boolean>;
                          globalDiscId: FieldsSelection<string | null, boolean>;
                          id: number;
                          index: number;
                          name: FieldsSelection<string | null, boolean>;
                          release: Release | null;
                          releaseId: number;
                          slug: FieldsSelection<string | null, boolean>;
                          titles: Pick<
                              {
                                  __typename: "Title";
                                  comment: (...)
                                  | (...);
                                  description: string;
                                  disc: (...) | (...);
                                  discItemReferenceId: (...) | (...);
                                  displaySize: FieldsSelection<(...), (...)>;
                                  duration: FieldsSelection<(...), (...)>;
                                  episode: string;
                                  filename: string;
                                  hasItem: boolean;
                                  id: number;
                                  index: number;
                                  item: FieldsSelection<(...), (...)>;
                                  itemType: string;
                                  season: string;
                                  segmentMap: FieldsSelection<(...), (...)>;
                                  size: any;
                                  sourceFile: FieldsSelection<(...), (...)>;
                                  tracks: (...)[];
                              },
                              | "index"
                              | "sourceFile"
                              | "segmentMap"
                              | "duration"
                              | "size"
                              | "displaySize"
                              | "item",
                          >[];
                      },
                      | "slug"
                      | "index"
                      | "name"
                      | "format"
                      | "contentHash"
                      | "globalDiscId"
                      | "titles",
                  >[];
                  fullTitle: string;
                  id: number;
                  imageUrl: FieldsSelection<string | null, boolean>;
                  isbn: string | null;
                  locale: FieldsSelection<string | null, boolean>;
                  mediaItem: MediaItem | null;
                  regionCode: FieldsSelection<string | null, boolean>;
                  releaseDate: any;
                  releaseGroups: ReleaseGroup[];
                  slug: FieldsSelection<string | null, boolean>;
                  title: FieldsSelection<string | null, boolean>;
                  type: string;
                  upc: FieldsSelection<string | null, boolean>;
                  year: number;
              },
              | "slug"
              | "locale"
              | "regionCode"
              | "year"
              | "title"
              | "imageUrl"
              | "discs"
              | "upc"
              | "asin",
          > & { mediaItem: MediaItemViaStandardQuery },
      >

      a matching release with required mediaItem prop, whose releases array contains all releases for the media item other than the one requested.

    • Fetch a release by its Universal Product Code (UPC).

      Parameters

      • upc: string | number

        the upc for the release, a 12-digit number

      Returns Promise<
          Pick<
              {
                  __typename: "Release";
                  asin: FieldsSelection<string | null, boolean>;
                  backImageUrl: string | null;
                  boxset: Boxset | null;
                  contributors: Contributor[];
                  dateAdded: any;
                  discs: Pick<
                      {
                          __typename: "ReleaseDisc";
                          contentHash: FieldsSelection<string | null, boolean>;
                          disc: Disc | null;
                          discId: number;
                          format: FieldsSelection<string | null, boolean>;
                          globalDiscId: FieldsSelection<string | null, boolean>;
                          id: number;
                          index: number;
                          name: FieldsSelection<string | null, boolean>;
                          release: Release | null;
                          releaseId: number;
                          slug: FieldsSelection<string | null, boolean>;
                          titles: Pick<
                              {
                                  __typename: "Title";
                                  comment: (...)
                                  | (...);
                                  description: string;
                                  disc: (...) | (...);
                                  discItemReferenceId: (...) | (...);
                                  displaySize: FieldsSelection<(...), (...)>;
                                  duration: FieldsSelection<(...), (...)>;
                                  episode: string;
                                  filename: string;
                                  hasItem: boolean;
                                  id: number;
                                  index: number;
                                  item: FieldsSelection<(...), (...)>;
                                  itemType: string;
                                  season: string;
                                  segmentMap: FieldsSelection<(...), (...)>;
                                  size: any;
                                  sourceFile: FieldsSelection<(...), (...)>;
                                  tracks: (...)[];
                              },
                              | "index"
                              | "sourceFile"
                              | "segmentMap"
                              | "duration"
                              | "size"
                              | "displaySize"
                              | "item",
                          >[];
                      },
                      | "slug"
                      | "index"
                      | "name"
                      | "format"
                      | "contentHash"
                      | "globalDiscId"
                      | "titles",
                  >[];
                  fullTitle: string;
                  id: number;
                  imageUrl: FieldsSelection<string | null, boolean>;
                  isbn: string | null;
                  locale: FieldsSelection<string | null, boolean>;
                  mediaItem: MediaItem | null;
                  regionCode: FieldsSelection<string | null, boolean>;
                  releaseDate: any;
                  releaseGroups: ReleaseGroup[];
                  slug: FieldsSelection<string | null, boolean>;
                  title: FieldsSelection<string | null, boolean>;
                  type: string;
                  upc: FieldsSelection<string | null, boolean>;
                  year: number;
              },
              | "slug"
              | "locale"
              | "regionCode"
              | "year"
              | "title"
              | "imageUrl"
              | "discs"
              | "upc"
              | "asin",
          > & { mediaItem: MediaItemViaStandardQuery },
      >

    • Ask the server to hash a disc's files. It should be preferred to do this locally when possible.

      This could be used to hash files uploaded to a web form on a browser that does not support the filesystem API (not tested - relies on date modified instead of date created, which are often the same, but perhaps not always)

      Parameters

      • files: (FileHashInfo | File)[]

        details for the relevant files from the disc.

        • DVD: the contents of VIDEO_TS
        • Blu-ray: every .m2ts file in BDMV/STREAM

      Returns Promise<string>

      the computed hash

    • Search media items and boxsets.

      Parameters

      • query: string

        Search string to find results with. The effective minimum query length is 2.

      • Optionaloptions: { limit: number }
        • limit: number

          Truncate the number of results returned. I have seen up to 467 results without providing a limit.

      Returns Promise<SearchResult[]>

      const results = await discdb.search("the mummy", { limit: 50 });
      console.log(results);
      // [
      // {
      // key: "movie-the-mummy-1999",
      // type: SearchType.Movie,
      // title: "The Mummy",
      // slug: "the-mummy-1999",
      // imageUrl: "Movie/the-mummy-1999/cover.jpg",
      // relativeUrl: "/movie/the-mummy-1999",
      // externalIds: {
      // imdb: "tt0120616",
      // tmdb: 564,
      // upc: 191329243763,
      // asin: "B0C25X1883",
      // },
      // groups: [],
      // },
      // // ...
      // {
      // key: "boxset-the-mummy-trilogy-4k",
      // type: SearchType.Boxset,
      // title: "The Mummy Trilogy 4K",
      // slug: "the-mummy-trilogy-4k",
      // imageUrl: "boxset/the-mummy-trilogy-4k.jpg",
      // relativeUrl: "/boxset/the-mummy-trilogy-4k",
      // externalIds: {},
      // groups: [],
      // },
      // // ...
      // ]