Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "lib/endpoints/Playlist"

Index

Variables

Const parsePlaylist

parsePlaylist: (...input: T) => R = utils.parser((response: any, playlistId: string) => {const header = response.header.musicDetailHeaderRenderer? response.header.musicDetailHeaderRenderer: response.header.musicEditablePlaylistDetailHeaderRenderer.header.musicDetailHeaderRendererconst playlist: Playlist = {title: header.title.runs[0],thumbnail:header.thumbnail.croppedSquareThumbnailRenderer.thumbnail.thumbnails,playlistId,content: [],subtitle: header.subtitle.runs,secondSubtitle: header.secondSubtitle.runs}return playlist})

Type declaration

    • (...input: T): R
    • Parameters

      • Rest ...input: T

      Returns R

Const parsePlaylistContents

parsePlaylistContents: (...input: T) => R = utils.parser((contents: any, playlistId: string, limit: number | undefined) => {const content: Song[] = []for (let i = 0; i < contents.length; ++i) {const e = contents[i].musicResponsiveListItemRendererif (limit && i > limit - 1) breakconst song = parseSong(e, playlistId)if (song) {content.push(song)}}return content})

Type declaration

    • (...input: T): R
    • Parameters

      • Rest ...input: T

      Returns R

Const parseSong

parseSong: (...input: T) => R = utils.parser((e: any, playlistId: string) => {const primaryTextRun =e.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0]const id = primaryTextRun?.navigationEndpoint?.watchEndpoint?.videoIdif (!id) {// NOTE: It is apparently possible to have items that don't have an ID!// The Web UI renders them as disabled, and the only available action is to// remove them from the playlist. For now, we will wimply omit them from// results, since having an optional ID would be quite a breaking changereturn}return {id,duration:e.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text,thumbnail: e.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails,title: primaryTextRun,author:e.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs,album:e.flexColumns[2].musicResponsiveListItemFlexColumnRenderer.text.runs?.[0],url: `https://music.youtube.com/watch?v=${id}&list=${playlistId}`} as Song})

Type declaration

    • (...input: T): R
    • Parameters

      • Rest ...input: T

      Returns R

Functions

Const addToPlaylist

  • addToPlaylist(cookie: string, args: { authUser?: undefined | number; userID?: undefined | string }, ids: string[], playlistId: string): Promise<{ error?: undefined | string; ids: string[]; playlistId: string; playlistName?: undefined | string; status: string }>
  • Add song(s) to playlist

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

    Parameters

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

      Array of song ids to add

    • playlistId: string

      ID of playlist

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

    {
    status: string
    playlistName?: string
    ids: string[]
    playlistId: string
    }

Const createPlaylist

  • createPlaylist(cookie: string, args: { authUser?: undefined | number; userID?: undefined | string }, 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

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

      Title

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

      Privacy Status of playlist

    • Optional description: undefined | string

      Description of playlist

    Returns Promise<{ id: string } | Error>

Const deletePlaylist

  • deletePlaylist(cookie: string, args: { authUser?: undefined | number; userID?: undefined | string }, id: string): Promise<{ id: string } | Error>
  • 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

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

      id of the playlist

    Returns Promise<{ id: string } | Error>

Const getPlaylist

  • getPlaylist(cookie: string, args: { authUser?: undefined | number; userID?: undefined | string }, id: string, limit?: undefined | number): Promise<Playlist>
  • Returns Playlist Info

    usage
     const api = new YTMUSIC(cookie)
     const data = await api.getPlaylist('RDAMVM5hFevwJ4JXI')

    Parameters

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

      playlist ID

    • Optional limit: undefined | number

    Returns Promise<Playlist>

    Playlist

Const removeFromPlaylist

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

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

    Parameters

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

      Array of song ids to remove

    • playlistId: string

      ID of playlist

    • Optional setVideoId: undefined | string

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

Generated using TypeDoc