Interface Subtitle

The Subtitle module provides a way to register custom subtitle downloaers that integrates into IINA's user interface. See Subtitle Provider for details.

Hierarchy

  • Subtitle

Methods

  • Creates a subtitle item with associated data, and a descriptor object.

    Example

    // the associated data can be any type;
    // the descriptor is used to display the data in IINA's UI
    const item = subtitle.item({
    name: "Subtitle Name",
    language: "English",
    rating: 4.5,
    downloads: 1000
    });

    Type Parameters

    • T

    Parameters

    • data: T

      The assiciated data of type T.

    • Optional desc: SubtitleItemDescriptor<T>

      Descriptor of the assiciated data, which determines how the data should be displayed in IINA's interface. Nornally, the descriptor is set globally by the subtitle provider.

    Returns SubtitleItem<T>

  • Register a subtitle source provider. If the provider is already registered, it will be replaced with the new one.

    Example

    subtitle.registerProvider("my-provider", {
    search: async () => {
    // search for subtitles
    const results = await searchSubtitles(core.status.title);
    // return an array of subtitle items
    return results.map(r => subtitle.item(r));
    },
    description: (item) => {
    // return description for this subtitle item
    },
    download: async (item) => {
    // download the subtitle files for this subtitle item
    const paths = await downloadSubtitle(item.data);
    return paths;
    },
    });

    Type Parameters

    • T

    Parameters

    Returns void

Generated using TypeDoc