Options
All
  • Public
  • Public/Protected
  • All
Menu

Barbara Music

Index

Functions

  • fetchGeniusSongLyrics(url: string): Promise<string[] | null>
  • Scrape lyrics data from song on Genius

    Parameters

    • url: string

      Genius song friendly URL

    Returns Promise<string[] | null>

  • freeKey(key: string): Promise<any>
  • Return a free authentication key (e.g. SoundCloud client ID). You can use this when setting a key instead of providing your own. A full reference of key names can be found on the cheatsheet.

    example
    // Get a free SoundCloud client ID and set it
    barbara.setKey("SOUNDCLOUD_CLIENTID", await barbara.freeKey("SOUNDCLOUD_CLIENTID"));

    // Get a better Invidious API and set it
    barbara.setKey("YOUTUBE_INVIDIOUSAPI", await barbara.freeKey("YOUTUBE_INVIDIOUSAPI"));

    Some code was ripped from play-dl

    async

    Function is asynchronous!

    Parameters

    • key: string

    Returns Promise<any>

  • getKey(key: string): boolean | string
  • Return an authentication key. A full reference of key names can be found on the cheatsheet.

    example
    // Get key for Spotify Client ID
    getKey("SPOTIFY_CLIENTID");

    Parameters

    • key: string

      Key identifier in the format of <SERVICE>_<KEYIDENTIFIER>

    Returns boolean | string

  • Automatically matches and returns a MusicTrack or MusicPlaylist from a given service URL

    example
    barbara.info("").then((track) => {

    })

    Parameters

    • url: string

    Returns Promise<MusicTrack | MusicPlaylist>

  • refreshTokens(service?: Service): Promise<void>
  • Automatically refresh all authenticated service keys. If CONFIG_AUTOREFRESH is true, this will occur automatically when tokens are about to expire.

    Parameters

    Returns Promise<void>

  • Searches for tracks with given query on SoundCloud, unless other service and type is specified in search options.

    Note: For YouTube, option.type = tracks and videos are the same thing.

    Parameters

    • query: string

      Search query

    • options: SearchOptions = {}

      Search options

    Returns Promise<MusicTrack[] | MusicPlaylist[]>

    Array of MusicTrack or MusicPlaylist objects

  • searchGeniusSong(query: string): Promise<GeniusSong | undefined>
  • Returns with song data from Genius API

    Parameters

    • query: string

      Query to search song

    Returns Promise<GeniusSong | undefined>

  • serviceFromURL(url: string): Promise<Service | undefined>
  • Validate and get the service from a given URL.

    Parameters

    • url: string

    Returns Promise<Service | undefined>

    Service or undefined

  • setKey(key: string, value: string): void
  • Set an authentication key (e.g. Spotify API key). A full reference of key names can be found on the cheatsheet.

    Use this function to set keys before invoking other Barbara-related stuff so Barbara can use the given keys.

    example
    // Set key for SoundCloud Client ID
    setKey("SOUNDCLOUD_CLIENTID", "when will soundcloud open dev program again 🤔");

    Parameters

    • key: string

      Key identifier in the format of <SERVICE>_<KEYIDENTIFIER>

    • value: string

      Key value

    Returns void

  • setKeyFile(path: string, overwrite?: boolean): void
  • Read a configuration file in JSON format and append to authenticaton keys.

    Parameters

    • path: string

      Path to configuration file

    • overwrite: boolean = true

      Overwrite keys that have been manually set? Defaults to true.

    Returns void

  • setKeys(ks: object): void
  • Set authentication keys in bulk. Note: will overwrite specified keys. A full reference of key names can be found on the cheatsheet.

    Use this function to set keys before invoking other Barbara-related stuff so Barbara can use the given keys.

    example
    setKeys({
    // Supports underscore format...
    "SOUNDCLOUD_CLIENTID": "1234567890",
    // ... or hierarchical format
    "SPOTIFY": {
    CLIENTID: "1234567890"
    }
    })

    Parameters

    • ks: object

      Object containing keys

    Returns void

Generated using TypeDoc