UNPKG

ytmusic_api_unofficial

Version:

A simple API to get music from YouTube Music

148 lines 3.86 kB
import { Thumbnail } from "./Thumbnail"; import Artist from "./Artist"; import Duration from "./Duration"; import { AvailableFormat, AvailableQuality } from "../utils/default"; import Album from "./Album"; import Playlist from "./Playlist"; export default class Music { /** * An array of available Artwork in different sizes * @example * ```json * [ * { * "url": "https://lh3.googleusercontent.com/...", * "width": 60, * "height": 60 * }, * ] * ``` */ thumbnails: Array<Thumbnail>; /** * The YTmusic id of the music * @example "dQw4w9WgXcQ" */ id: string; /** * The title of the music * @example "Never Gonna Give You Up" */ title: string; /** * An array of Artist objects * @example * ```json * [ * { * "name": "Rick Astley", * "id": "MPREb_5eN7fQq3J9_" * } * ] * ``` */ artists: Array<Artist>; /** * The type of the video * @example "song" | "video" | "album"... etc. (Check available types) */ resultType: string; /** * The YouTube type of the music * @example "MUSIC_VIDEO_TYPE_ATV" */ videoType: string; /** * The duration of the music * @example * ```json * { * "duration": 213, // in seconds * "formatted": "3:33", * "formattedLong": "3 minutes, 33 seconds" * } * ``` */ duration: Duration; /** * The browseId of the music (NOT WORKING) * @example "MPREb_5eN7fQq3J9_" * @TODO Fix this */ browseID: string; /** * If the music is audio only (considerably reduces the risk of unwanted sounds in the middle of a song) * @example true */ isAudioOnly: boolean; /** * Return the album of the music if it's available */ album?: Album; /** * The year of the music if it's available * @example 2024 */ year?: number; /** * If the music contains explicit content * @example false */ isExplicit: boolean; /** * The relative browseId of the music (used for fetching related songs) * @example "MPREb_5eN7fQq3J9_" */ relativeBrowseID: string; /** * Is defined as a top result by YouTube Music (but not always true. Please refer to searchRanking field) * @example false */ isTopResult: boolean; /** * Search matching index * @public * @example 0 */ searchRanking: number; private readonly radioPlaylistID; private readonly radioPlaylistCode; constructor(data: any); /** * Get the name of the artists separated by a comma * @example "Rick Astley, Foo Fighters" * @example * ```js * const get = await ytMusic.get("Never Gonna Give You Up") * console.log(get.artistsNames) * // Output: "Rick Astley" * ``` * @returns The name of the artists */ get artistsNames(): string; /** * Get the lyrics of the music if it's available * @returns The lyrics of the music */ getLyrics(): Promise<{ lyrics: string; source: any; }>; /** * Download the music * @param format - The format of the music (Check available formats) * @param quality - The quality of the music (Check available qualities) **/ download(format?: AvailableFormat, quality?: AvailableQuality): Promise<any>; /** * Get the radio playlist of the music */ getRadioPlaylist(): Promise<Playlist>; /** * Return Thumbnail with custom size * @param width - The width of the thumbnail * @param height - The height of the thumbnail */ getThumbnail(width: number, height: number): Thumbnail; } //# sourceMappingURL=Music.d.ts.map