Options
All
  • Public
  • Public/Protected
  • All
Menu

Class YTMUSIC

Hierarchy

  • YTMUSIC

Index

Constructors

constructor

  • new YTMUSIC(cookie: string, args?: undefined | { authUser?: undefined | number; userID: string }): YTMUSIC
  • Parameters

    • cookie: string
    • Optional args: undefined | { authUser?: undefined | number; userID: string }

    Returns YTMUSIC

Properties

Private Optional args

args: undefined | { authUser?: undefined | number; userID: string }

authUser

authUser: number | undefined

Private cookie

cookie: string

Optional userID

userID: undefined | string

Methods

addToPlaylist

  • addToPlaylist(ids: string[], playlistId: string): Promise<{ error?: undefined | string; ids: string[]; playlistId: string; playlistName?: undefined | string; status: string }>
  • Parameters

    • ids: string[]
    • playlistId: string

    Returns Promise<{ error?: undefined | string; ids: string[]; playlistId: string; playlistName?: undefined | string; status: string }>

createPlaylist

  • createPlaylist(title: string, privacyStatus: "PRIVATE" | "PUBLIC" | "UNLISTED", description?: undefined | string): Promise<{ id: string } | Error>
  • Create playlist

    usage
     const api = new YTMUSIC(cookie)
     const data = await api.createPlaylist('Summer Songs', 'PUBLIC', 'Some songs for summer')
     await api.addToPlaylist(['-mLpe7KUg9U', '5hFevwJ4JXI'], playlist.id)

    Parameters

    • title: string

      Title

    • privacyStatus: "PRIVATE" | "PUBLIC" | "UNLISTED"

      Privacy Status of playlist

    • Optional description: undefined | string

      Description of playlist

    Returns Promise<{ id: string } | Error>

deletePlaylist

  • deletePlaylist(id: string): Promise<Error | { id: string }>
  • Delete playlist

    usage
     const api = new YTMUSIC(cookie)
     const data = await api.createPlaylist('Summer Songs', 'PUBLIC', 'Some songs for summer')
     await api.deletePlaylist(playlist.id)

    Parameters

    • id: string

      id of the playlist

    Returns Promise<Error | { id: string }>

getArtist

  • getArtist(channelId: string): Promise<Error | Artist>

getFullHomePage

  • Returns Full HomePage

    usage
     const api = new YTMUSIC(cookie)
     const data = await api.getFullHomePage()

    Returns Promise<HomePage>

    HomePage

getHomePage

  • Returns First Part of HomePage

    usage
     const api = new YTMUSIC(cookie)
     const data = await api.getHomePage()

    You can call data.continue() to get next part

    Returns Promise<HomePage>

    HomePage

getPlaylist

  • getPlaylist(id: string, limit?: undefined | number): Promise<Playlist>
  • Parameters

    • id: string
    • Optional limit: undefined | number

    Returns Promise<Playlist>

getPlaylists

  • getPlaylists(): Promise<Error | Playlist[]>

getSongInfo

  • getSongInfo(url: string): Promise<Song>
  • Get song info

    usage
     const api = new YTMUSIC(cookie)
     const song = await api.getSongInfo('https://music.youtube.com/watch?v=DPXHMBKY39M&feature=share')
     console.log(song.title)

    Parameters

    • url: string

      Search query

    Returns Promise<Song>

removeFromPlaylist

  • removeFromPlaylist(ids: string[], playlistId: string, setVideoId?: undefined | string): Promise<Error | { ids: string[]; playlistId: string; playlistName?: undefined | string; status: string }>
  • Remove song(s) from playlist

    usage
     const api = new YTMUSIC(cookie)
     const data = await api.removeFromPlaylist(['-mLpe7KUg9U', '5hFevwJ4JXI'], 'RDAMVM5hFevwJ4JXI')

    Parameters

    • ids: string[]

      Array of song ids to remove

    • playlistId: string

      ID of playlist

    • Optional setVideoId: undefined | string

    Returns Promise<Error | { ids: string[]; playlistId: string; playlistName?: undefined | string; status: string }>

search

  • search(query: string, options?: undefined | { filter?: "songs" | "albums" | "playlists" | "videos" | "artists"; max?: undefined | number }): Promise<Error | { album?: Text; author?: Text; id?: undefined | string; thumbnails: Thumbnail[]; title: Text; tracksCount?: undefined | number; type: "song" | "album" | "playlist" | "video" | "artist"; url: string }[]>
  • Search

    usage
     const api = new YTMUSIC(cookie)
     const data = await api.createPlaylist('Summer Songs', 'PUBLIC', 'Some songs for summer')
     const songs = await api.search('Hot stuff')
     await api.addToPlaylist([songs[0].id], playlist.id)

    Parameters

    • query: string

      Search query

    • Optional options: undefined | { filter?: "songs" | "albums" | "playlists" | "videos" | "artists"; max?: undefined | number }

    Returns Promise<Error | { album?: Text; author?: Text; id?: undefined | string; thumbnails: Thumbnail[]; title: Text; tracksCount?: undefined | number; type: "song" | "album" | "playlist" | "video" | "artist"; url: string }[]>

Generated using TypeDoc