M3u parser class to parse m3u playlist string to playlist object

Hierarchy

  • M3uParser

Constructors

Methods

  • Private

    Get m3u attributes object from attributes string

    Returns

    attributes object e.g. {"tvg-id": "", "group-title": ""}

    Parameters

    • attributesString: string

      e.g. 'tvg-id="" group-title=""'

    Returns M3uAttributes

  • Private

    Is directive method detect if line contains m3u directive

    Returns

    true if it is line with directive, otherwise false

    Parameters

    • item: string

      string line of playlist

    Returns boolean

  • Private

    Is valid m3u method detect if first line of playlist contains #EXTM3U directive

    Returns

    true if line starts with #EXTM3U, false otherwise

    Parameters

    • firstLine: string[]

      first line of m3u playlist string

    Returns boolean

  • Parse is static method to parse m3u playlist string into m3u playlist object. Playlist need to contain #EXTM3U directive on first line. All lines are trimmed and blank ones are removed.

    Returns

    parsed m3u playlist object

    Example

    const playlist = M3uParser.parse(m3uString);
    playlist.medias.forEach(media => media.location);

    Parameters

    • m3uString: string

      whole m3u playlist string

    • Optional config: M3uParserConfig

      additional parsing configuration

    Returns M3uPlaylist

  • Private

    Process custom unknown directive and add it into playlist or media object, based on mapping configuration

    Parameters

    • playlist: M3uPlaylist

      m3u playlist object processed until now

    • media: M3uMedia

      actual m3u media object

    • trackInformation: string

      track information, whole part of string after directive and semicolon

    • directive: string

      unknown directive e.g. #EXT-CUSTOM

    • customDataMapping: M3uCustomDataMapping

      whole custom directive data mapping configuration

    Returns void

  • Private

    Process directive method detects directive on line and call proper method to another processing

    Parameters

    • item: string

      actual line of m3u playlist string e.g. '#EXTINF:-1 tvg-id="" group-title="",Tv Name'

    • customDataMapping: M3uCustomDataMapping

      whole custom directive data mapping configuration

    • playlist: M3uPlaylist

      m3u playlist object processed until now

    • media: M3uMedia

      actual m3u media object

    Returns void

  • Private

    Process media method parse trackInformation and fill media with parsed info

    Parameters

    • trackInformation: string

      media substring of m3u string line e.g. '-1 tvg-id="" group-title="",Tv Name'

    • media: M3uMedia

      actual m3u media object

    Returns void

Generated using TypeDoc