Merge branch 'vuepress' into main

This commit is contained in:
Zechariah 2022-03-30 23:16:20 +08:00
commit 641f695f9f
58 changed files with 2864 additions and 414 deletions

4
.gitignore vendored
View File

@ -3,4 +3,6 @@
**/dist
**/config.json
**/*.test.ts
**/.vscode
**/.vscode
**/.temp
**/.cache

1
.npmrc Normal file
View File

@ -0,0 +1 @@
shamefully-hoist=true

395
README.md
View File

@ -5,6 +5,7 @@
YouTube Music API (Unofficial) is a YouTube Music data scraper. It comes with TypeScript support API for return types. The NPM Package can be found [here](https://npmjs.com/package/ytmusic-api)
## Motivation
I used to use [youtube-music-api](https://npmjs.com/package/youtube-music-api) as my youtube music api data scraper. I liked looking into the source code of how it works but it never made sense to me. I also didn't like that there were no TypeScript annotations for the return types of methods.
Because of this, I decided to build my own version of a youtube music api with TypeScript annotations, testing and written in a way I can understand.
@ -20,400 +21,8 @@ Because of this, I decided to build my own version of a youtube music api with T
- Albums
- Playlists
## Installation
```
$ npm i ytmusic-api
```
## Usage
Import YTMusic from the npm package
```ts
// TypeScript
import YTMusic from "ytmusic-api"
// JavaScript
const YTMusic = require("ytmusic-api")
```
Create an instance of the class `YTMusic`.
Then, call the `initialize()` to initialize the API before using the API anywhere
```ts
const ytmusic = new YTMusic()
ytmusic.initialize().then(() => {
// Use API here
})
```
### Methods to fetch data
#### `getSearchSuggestions`
This function takes in the following parameters
| Name | Data Type | Description |
| :---- | :-------- | :------------------------------------ |
| query | `string` | Search query you want suggestions for |
The function returns a `Promise<string[]>` which are the suggestion results
```ts
ytmusic.getSearchSuggestions("Lilac").then(res => {
console.log(res)
})
```
#### `search`
This function takes in the following parameters
| Name | Data Type | Description |
| :------- | :-------------------------------------------------------------------- | :---------------------------------------------------------------------------------- |
| query | `string` | Search query |
| category | `"SONG" \| "VIDEO" \| "ARTIST" \| "ALBUM" \| "PLAYLIST" \| undefined` | Type of results to search for. If not specified, returns all types of search result |
The function **when nothing is passed as the category** returns a `Promise<`[SearchResult](#SearchResult)`[]>` which are the search results of all categories
```ts
ytmusic.search("Lilac").then(results => {
console.log(results)
})
```
##### `search (category = "SONG")`
When you pass in `"SONG"` as the category,
The function returns a `Promise<`[SongDetailed](#SongDetailed)`[]>` which are the song results
```ts
ytmusic.search("Lilac", "SONG").then(songs => {
console.log(songs)
})
```
##### `search (category = "VIDEO")`
When you pass in `"VIDEO"` as the category,
The function returns a `Promise<`[VideoDetailed](#VideoDetailed)`[]>` which are the video results
```ts
ytmusic.search("Lilac", "VIDEO").then(videos => {
console.log(videos)
})
```
##### `search (category = "ARTIST")`
When you pass in `"ARTIST"` as the category
The function returns a `Promise<`[ArtistDetailed](#ArtistDetailed)`[]>` which are the artist results
```ts
ytmusic.search("Lilac", "ARTIST").then(artists => {
console.log(artists)
})
```
##### `search (category = "ALBUM")`
When you pass in `"ALBUM"` as the category,
The function returns a `Promise<`[AlbumDetailed](#AlbumDetailed)`[]>` which are the album results
```ts
ytmusic.search("Lilac", "ALBUM").then(albums => {
console.log(albums)
})
```
##### `search (category = "PLAYLIST")`
When you pass in `"PLAYLIST"` as the category,
The function returns a `Promise<`[PlaylistFull](#PlaylistFull)`[]>` which are the playlist results
```ts
ytmusic.search("Lilac", "PLAYLIST").then(playlists => {
console.log(playlists)
})
```
#### `getSong`
This function takes in the following parameters
| Name | Data Type | Description |
| :------ | :-------- | :---------- |
| videoId | `string` | Video ID |
The function returns a `Promise<`[SongFull](#SongFull)`>` which is the information about the song
```ts
ytmusic.getSong("v7bnOxV4jAc").then(song => {
console.log(song)
})
```
#### `getVideo`
This function takes in the following parameters
| Name | Data Type | Description |
| :------ | :-------- | :---------- |
| videoId | `string` | Video ID |
The function returns a `Promise<`[VideoFull](#VideoFull)`>` which is the information about the video
```ts
ytmusic.getVideo("v7bnOxV4jAc").then(video => {
console.log(video)
})
```
#### `getArtist`
This function takes in the following parameters
| Name | Data Type | Description |
| :------- | :-------- | :---------- |
| artistId | `string` | Artist ID |
The function returns a `Promise<`[ArtistFull](#ArtistFull)`>` which is the information about the artist
```ts
ytmusic.getArtist("UCTUR0sVEkD8T5MlSHqgaI_Q").then(artist => {
console.log(artist)
})
```
#### `getArtistSongs`
This function takes in the following parameters
| Name | Data Type | Description |
| :------- | :-------- | :---------- |
| artistId | `string` | Artist ID |
The function returns a `Promise<`[SongDetailed](#SongDetailed)`[]>` which is the information about all the artist's songs
```ts
ytmusic.getArtistSongs("UCTUR0sVEkD8T5MlSHqgaI_Q").then(artistSongs => {
console.log(artistSongs)
})
```
#### `getArtistAlbums`
This function takes in the following parameters
| Name | Data Type | Description |
| :------- | :-------- | :---------- |
| artistId | `string` | Artist ID |
The function returns a `Promise<`[AlbumDetailed](#AlbumDetailed)`[]>` which is the information about all the artist's albums
```ts
ytmusic.getArtistAlbums("UCTUR0sVEkD8T5MlSHqgaI_Q").then(artistAlbums => {
console.log(artistAlbums)
})
```
#### `getAlbum`
This function takes in the following parameters
| Name | Data Type | Description |
| :------ | :-------- | :---------- |
| albumId | `string` | Album ID |
The function returns a `Promise<`[AlbumFull](#AlbumFull)`>` which is the information about the album
```ts
ytmusic.getAlbum("MPREb_iG5q5DIdhdA").then(album => {
console.log(album)
})
```
#### `getPlaylist`
This function takes in the following parameters
| Name | Data Type | Description |
| :--------- | :-------- | :---------- |
| playlistId | `string` | Playlist ID |
The function returns a `Promise<`[PlaylistFull](#PlaylistFull)`>` which is the information about the playlist (without the videos)
```ts
ytmusic.getPlaylist("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(playlist => {
console.log(playlist)
})
```
#### `getPlaylistVideos`
This function takes in the following parameters
| Name | Data Type | Description |
| :--------- | :-------- | :---------- |
| playlistId | `string` | Playlist ID |
The function returns a `Promise<Omit<`[VideoDetailed](#VideoDetailed)`, "views">[]>` which is the information about the videos without the view count
```ts
ytmusic.getPlaylistVideos("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(playlistVideos => {
console.log(playlistVideos)
})
```
### Data Types
#### `ThumbnailFull`
| Name | Data Type | Description |
| :----- | :-------- | :------------------ |
| url | `string` | Link |
| width | `number` | Width of the image |
| height | `number` | Height of the image |
#### `SongDetailed`
| Name | Data Type | Description |
| :--------- | :---------------------------------- | :------------------ |
| type | `"SONG"` | Type of data |
| videoId | `string` | YouTube Video ID |
| name | `string` | Name |
| artists | [ArtistBasic](#ArtistBasic)`[]` | Artists |
| album | [AlbumBasic](#AlbumBasic) | Album |
| duration | `number` | Duration in seconds |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
#### `SongFull`
| Name | Data Type | Description |
| :-------------- | :---------------------------------- | :--------------------- |
| type | `"SONG"` | Type of data |
| videoId | `string` | YouTube Video ID |
| name | `string` | Name |
| artists | [ArtistBasic](#ArtistBasic)`[]` | Artists |
| duration | `number` | Duration in seconds |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
| description | `string` | Description |
| formats | `any[]` | Video Formats |
| adaptiveFormats | `any[]` | Adaptive Video Formats |
#### `VideoDetailed`
| Name | Data Type | Description |
| :--------- | :---------------------------------- | :------------------------------ |
| type | `"VIDEO"` | Type of data |
| videoId | `string` | YouTube Video ID |
| name | `string` | Name |
| artists | [ArtistBasic](#ArtistBasic)`[]` | Channels that created the video |
| views | `number` | View count |
| duration | `number` | Duration in seconds |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
#### `VideoFull`
| Name | Data Type | Description |
| :---------- | :---------------------------------- | :------------------------------------- |
| type | `"VIDEO"` | Type of data |
| videoId | `string` | YouTube Video ID |
| name | `string` | Name |
| artists | [ArtistBasic](#ArtistBasic)`[]` | Channels that created the video |
| views | `number` | View count |
| duration | `number` | Duration in seconds |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
| description | `string` | Description |
| unlisted | `boolean` | If the video is unlisted on YouTube |
| familySafe | `boolean` | If the video is family safe on YouTube |
| paid | `boolean` | If the video is paid on YouTube |
| tags | `string[]` | Tags |
#### `ArtistBasic`
| Name | Data Type | Description |
| :------- | :--------------- | :---------- |
| artistId | `string` | Artist ID |
| name | `string` | Name |
#### `ArtistDetailed`
| Name | Data Type | Description |
| :--------- | :---------------------------------- | :----------- |
| type | `"ARTIST"` | Type of data |
| artistId | `string` | Artist ID |
| name | `string` | Name |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
#### `ArtistFull`
| Name | Data Type | Description |
| :---------- | :---------------------------------------------------- | :----------------------------------- |
| type | `"ARTIST"` | Type of data |
| artistId | `string` | Artist ID |
| name | `string` | Name |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
| description | `string` | Description |
| subscribers | `number` | Number of subscribers the Artist has |
| topSongs | `Omit<`[SongDetailed](#SongDetailed)`, "duration">[]` | Top Songs from Artist |
| topAlbums | [AlbumDetailed](#AlbumDetailed)`[]` | Top Albums from Artist |
#### `AlbumBasic`
| Name | Data Type | Description |
| :------ | :-------- | :---------- |
| albumId | `string` | Album ID |
| name | `string` | Name |
#### `AlbumDetailed`
| Name | Data Type | Description |
| :--------- | :---------------------------------- | :-------------------- |
| type | `"ALBUM"` | Type of data |
| albumId | `string` | Album ID |
| playlistId | `string` | Playlist ID for Album |
| name | `string` | Name |
| artists | [ArtistBasic](#ArtistBasic)`[]` | Creators of the Album |
| year | `number` | Publication Year |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
#### `AlbumFull`
| Name | Data Type | Description |
| :---------- | :---------------------------------- | :-------------------- |
| type | `"ALBUM"` | Type of data |
| albumId | `string` | Album ID |
| playlistId | `string` | Playlist ID for Album |
| name | `string` | Name |
| artists | [ArtistBasic](#ArtistBasic)`[]` | Creators of the Album |
| year | `number` | Publication Year |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
| description | `string` | Description |
| songs | [SongDetailed](#SongDetailed)`[]` | Songs in the Album |
#### `PlaylistFull`
| Name | Data Type | Description |
| :--------- | :---------------------------------- | :------------------------------- |
| type | `"PLAYLIST"` | Type of data |
| playlistId | `string` | Playlist ID |
| name | `string` | Name |
| artist | [ArtistBasic](#ArtistBasic) | Creator of the Playlist |
| videoCount | `number` | Number of videos in the Playlist |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
#### `SearchResult`
[SongDetailed](#SongDetailed) or [VideoDetailed](#VideoDetailed) or [ArtistDetailed](#ArtistDetailed) or [AlbumDetailed](#AlbumDetailed) or [PlaylistFull](#PlaylistFull)
## Credits
A lot of the credit should go to [youtube-music-api](https://npmjs.com/package/youtube-music-api). I build this package as a refactored and tested version of youtube-music-api with TypeScript annotations
## Testing

251
docs/.vuepress/config.ts Normal file
View File

@ -0,0 +1,251 @@
import { defineUserConfig } from "vuepress"
import type { DefaultThemeOptions } from "vuepress"
export default defineUserConfig<DefaultThemeOptions>({
title: "YTMusic API",
description: "Unofficial YouTube Music API for TypeScript",
plugins: [
[
"@vuepress/plugin-search",
{
locales: {
"/": {
placeholder: "Search"
}
}
}
]
],
themeConfig: {
repo: "zS1L3NT/ts-npm-ytmusic-api",
editLink: false,
navbar: [
{
text: "Home",
link: "/"
},
{
text: "Guides",
link: "/guides/getting-started.html"
},
{
text: "References",
link: "/references/ytmusic.html"
}
],
sidebar: [
{
text: "Guides",
collapsible: true,
children: [
{
text: "Getting Started",
link: "/guides/getting-started.html"
},
{
text: "Usage",
link: "/guides/usage.html",
children: [
{
text: "Getting search suggestions",
link: "/guides/usage/getSearchSuggestions.html"
},
{
text: "Searching for results",
link: "/guides/usage/search.html"
},
{
text: "Searching for songs",
link: "/guides/usage/searchSongs.html"
},
{
text: "Searching for videos",
link: "/guides/usage/searchVideos.html"
},
{
text: "Searching for artists",
link: "/guides/usage/searchArtists.html"
},
{
text: "Searching for albums",
link: "/guides/usage/searchAlbums.html"
},
{
text: "Searching for playlists",
link: "/guides/usage/searchPlaylists.html"
},
{
text: "Getting a song",
link: "/guides/usage/getSong.html"
},
{
text: "Getting a video",
link: "/guides/usage/getVideo.html"
},
{
text: "Getting an artist",
link: "/guides/usage/getArtist.html"
},
{
text: "Getting an artist's top songs",
link: "/guides/usage/getArtistSongs.html"
},
{
text: "Getting an artist's top albums",
link: "/guides/usage/getArtistAlbums.html"
},
{
text: "Getting an album",
link: "/guides/usage/getAlbum.html"
},
{
text: "Getting a playlist",
link: "/guides/usage/getPlaylist.html"
},
{
text: "Getting a playlist's videos",
link: "/guides/usage/getPlaylistVideos.html"
}
]
}
]
},
{
text: "References",
collapsible: true,
children: [
{
text: "YTMusic Class",
link: "/references/ytmusic.html",
children: [
{
text: "getSearchSuggestions",
link: "/references/ytmusic/getSearchSuggestions.html"
},
{
text: "search",
link: "/references/ytmusic/search.html"
},
{
text: "searchSongs",
link: "/references/ytmusic/searchSongs.html"
},
{
text: "searchVideos",
link: "/references/ytmusic/searchVideos.html"
},
{
text: "searchArtists",
link: "/references/ytmusic/searchArtists.html"
},
{
text: "searchAlbums",
link: "/references/ytmusic/searchAlbums.html"
},
{
text: "searchPlaylists",
link: "/references/ytmusic/searchPlaylists.html"
},
{
text: "getSong",
link: "/references/ytmusic/getSong.html"
},
{
text: "getVideo",
link: "/references/ytmusic/getVideo.html"
},
{
text: "getArtist",
link: "/references/ytmusic/getArtist.html"
},
{
text: "getArtistSongs",
link: "/references/ytmusic/getArtistSongs.html"
},
{
text: "getArtistAlbums",
link: "/references/ytmusic/getArtistAlbums.html"
},
{
text: "getAlbum",
link: "/references/ytmusic/getAlbum.html"
},
{
text: "getPlaylist",
link: "/references/ytmusic/getPlaylist.html"
},
{
text: "getPlaylistVideos",
link: "/references/ytmusic/getPlaylistVideos.html"
}
]
},
{
text: "Interfaces",
link: "/references/interfaces.html",
children: [
{
text: "ThumbnailFull",
link: "/references/interfaces/ThumbnailFull.html"
},
{
text: "SongDetailed",
link: "/references/interfaces/SongDetailed.html"
},
{
text: "SongFull",
link: "/references/interfaces/SongFull.html"
},
{
text: "VideoDetailed",
link: "/references/interfaces/VideoDetailed.html"
},
{
text: "VideoFull",
link: "/references/interfaces/VideoFull.html"
},
{
text: "ArtistBasic",
link: "/references/interfaces/ArtistBasic.html"
},
{
text: "ArtistDetailed",
link: "/references/interfaces/ArtistDetailed.html"
},
{
text: "ArtistFull",
link: "/references/interfaces/ArtistFull.html"
},
{
text: "AlbumBasic",
link: "/references/interfaces/AlbumBasic.html"
},
{
text: "AlbumDetailed",
link: "/references/interfaces/AlbumDetailed.html"
},
{
text: "AlbumFull",
link: "/references/interfaces/AlbumFull.html"
},
{
text: "PlaylistFull",
link: "/references/interfaces/PlaylistFull.html"
}
]
},
{
text: "Types",
link: "/references/types.html",
children: [
{
text: "SearchResult",
link: "/references/types/SearchResult.html"
}
]
}
]
}
]
}
})

View File

@ -0,0 +1,5 @@
:root {
scroll-behavior: smooth;
--c-brand: #e6404b !important;
--c-brand-light: #f03441 !important;
}

17
docs/README.md Normal file
View File

@ -0,0 +1,17 @@
---
home: true
actions:
- text: Get Started
link: /guides/getting-started.html
type: primary
- text: NPM Registry
link: https://npmjs.org/package/ytmusic-api
type: secondary
features:
- title: YouTube Music Scraper
details: YTMusic API scrapes https://music.youtube.com for results and formats it for you
- title: TypeScript Support
details: You will receive TypeScript annotations when calling YouTube Music API with this package
- title: Type Error Detection
details: If there are type errors at runtime, the bug will be spotted and will show in the console
---

View File

@ -0,0 +1,41 @@
# Getting Started
## Overview
YTMusic API is an npm package that scrapes data from YouTube Music and formats it for you.
## Installation
<CodeGroup>
<CodeGroupItem title="npm" active="true">
```bash:no-line-numbers
npm i ytmusic-api
```
</CodeGroupItem>
<CodeGroupItem title="yarn">
```bash:no-line-numbers
yarn add ytmusic-api
```
</CodeGroupItem>
<CodeGroupItem title="pnpm">
```bash:no-line-numbers
pnpm i ytmusic-api
```
</CodeGroupItem>
</CodeGroup>
## Importing
```ts
// ES6 Import
import YTMusic from "ytmusic-api"
// Node Require
const YTMusic = require("ytmusic-api").default
```

12
docs/guides/usage.md Normal file
View File

@ -0,0 +1,12 @@
# Usage
YTMusic provides you many ways of fetching data from YouTube Music<br />
To leverage all the functions, we will need to create an instance of the class `YTMusic`.
Then, call the `initialize()` to initialize the API before using the API anywhere
```ts
const ytmusic = new YTMusic()
ytmusic.initialize().then(() => {
// Use API here
})
```

View File

@ -0,0 +1,11 @@
# Getting an album
`getAlbum()` will fetch you information about a specific album by it's ID.
```ts
ytmusic.getAlbum("MPREb_iG5q5DIdhdA").then(album => {
console.log(album)
})
```
See the [reference](../../references/ytmusic/getAlbum.html) for more information.

View File

@ -0,0 +1,11 @@
# Getting an artist
`getArtist()` will fetch you information about a specific artist by it's ID.
```ts
ytmusic.getArtist("UCTUR0sVEkD8T5MlSHqgaI_Q").then(artist => {
console.log(artist)
})
```
See the [reference](../../references/ytmusic/getArtist.html) for more information.

View File

@ -0,0 +1,11 @@
# Getting an artist's albums
`getArtistAlbums()` will fetch you information about a specific artist's albums by it's ID.
```ts
ytmusic.getArtistAlbums("UCTUR0sVEkD8T5MlSHqgaI_Q").then(artistAlbums => {
console.log(artistAlbums)
})
```
See the [reference](../../references/ytmusic/getArtistAlbums.html) for more information.

View File

@ -0,0 +1,11 @@
# Getting an artist's songs
`getArtistSongs()` will fetch you information about a specific artist's songs by it's ID.
```ts
ytmusic.getArtistSongs("UCTUR0sVEkD8T5MlSHqgaI_Q").then(artistSongs => {
console.log(artistSongs)
})
```
See the [reference](../../references/ytmusic/getArtistSongs.html) for more information.

View File

@ -0,0 +1,11 @@
# Getting a playlist
`getPlaylist()` will fetch you information about a specific playlist by it's ID.
```ts
ytmusic.getPlaylist("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(playlist => {
console.log(playlist)
})
```
See the [reference](../../references/ytmusic/getPlaylist.html) for more information.

View File

@ -0,0 +1,11 @@
# Getting an playlist's videos
`getPlaylistVideos()` will fetch you information about a specific playlist's videos by it's ID.
```ts
ytmusic.getPlaylistVideos("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(playlistVideos => {
console.log(playlistVideos)
})
```
See the [reference](../../references/ytmusic/getPlaylistVideos.html) for more information.

View File

@ -0,0 +1,20 @@
# Getting search suggestions
`getSearchSuggestions()` will fetch you a list of search suggestions based on the query
```ts
ytmusic.getSearchSuggestions("Lilac").then(res => {
console.log(res)
})
// > [
// > "lilac",
// > "lilac iu",
// > "lilac band",
// > "lilac wine",
// > "lilac wine miley cyrus",
// > "lilac close my eyes forever",
// > "lilac holy diver"
// > ]
```
See the [reference](../../references/ytmusic/getSearchSuggestions.html) for information.

View File

@ -0,0 +1,11 @@
# Getting a song
`getSong()` will fetch you information about a specific song by it's ID.
```ts
ytmusic.getSong("v7bnOxV4jAc").then(song => {
console.log(song)
})
```
See the [reference](../../references/ytmusic/getSong.html) for more information.

View File

@ -0,0 +1,11 @@
# Getting a video
`getVideo()` will fetch you information about a specific video by it's ID.
```ts
ytmusic.getVideo("v7bnOxV4jAc").then(video => {
console.log(video)
})
```
See the [reference](../../references/ytmusic/getVideo.html) for more information.

View File

@ -0,0 +1,11 @@
# Searching for results
`search()` will search YTMusic for any type of result.
```ts
ytmusic.search("Lilac").then(results => {
console.log(results)
})
```
See the [reference](../../references/ytmusic/search.html) for information.

View File

@ -0,0 +1,11 @@
# Searching for albums
`searchAlbums()` will search YTMusic for album results.
```ts
ytmusic.searchAlbums("Lilac").then(albums => {
console.log(albums)
})
```
See the [reference](../../references/ytmusic/searchAlbums.html) for information.

View File

@ -0,0 +1,11 @@
# Searching for artists
`searchArtists()` will search YTMusic for artist results.
```ts
ytmusic.searchArtists("Lilac").then(artists => {
console.log(artists)
})
```
See the [reference](../../references/ytmusic/searchArtists.html) for information.

View File

@ -0,0 +1,11 @@
# Searching for playlists
`searchPlaylists()` will search YTMusic for playlist results.
```ts
ytmusic.searchPlaylists("Lilac").then(playlists => {
console.log(playlists)
})
```
See the [reference](../../references/ytmusic/searchPlaylists.html) for information.

View File

@ -0,0 +1,11 @@
# Searching for songs
`searchSongs()` will search YTMusic for song results.
```ts
ytmusic.searchSongs("Lilac").then(songs => {
console.log(songs)
})
```
See the [reference](../../references/ytmusic/searchSongs.html) for information.

View File

@ -0,0 +1,11 @@
# Searching for songs
`searchVideos()` will search YTMusic for video results.
```ts
ytmusic.searchVideos("Lilac").then(videos => {
console.log(videos)
})
```
See the [reference](../../references/ytmusic/searchVideos.html) for information.

View File

@ -0,0 +1,14 @@
# Interfaces
- [ThumbnailFull](./interfaces/ThumbnailFull.html)
- [SongDetailed](./interfaces/SongDetailed.html)
- [SongFull](./interfaces/SongFull.html)
- [VideoDetailed](./interfaces/VideoDetailed.html)
- [VideoFull](./interfaces/VideoFull.html)
- [ArtistBasic](./interfaces/ArtistBasic.html)
- [ArtistDetailed](./interfaces/ArtistDetailed.html)
- [ArtistFull](./interfaces/ArtistFull.html)
- [AlbumBasic](./interfaces/AlbumBasic.html)
- [AlbumDetailed](./interfaces/AlbumDetailed.html)
- [AlbumFull](./interfaces/AlbumFull.html)
- [PlaylistFull](./interfaces/PlaylistFull.html)

View File

@ -0,0 +1,21 @@
# AlbumBasic
## Properties
| Name | Data Type | Description |
| :-------- | :-------- | :---------- |
| `albumId` | `string` | Album ID |
| `name` | `string` | Name |
## TypeScript Source Code
```ts
interface AlbumBasic {
albumId: string
name: string
}
```
## Usages
[SongDetailed#album](./SongDetailed.html)

View File

@ -0,0 +1,37 @@
# AlbumDetailed
## Properties
| Name | Data Type | Description |
| :----------- | :---------------------------------------- | :-------------------- |
| `type` | `"ALBUM"` | Type of data |
| `albumId` | `string` | Album ID |
| `playlistId` | `string` | Playlist ID for Album |
| `name` | `string` | Name |
| `artists` | [ArtistBasic](./ArtistBasic.html)`[]` | Creators of the Album |
| `year` | `number` | Publication Year |
| `thumbnails` | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
## TypeScript Source Code
```ts
interface AlbumDetailed {
type: "ALBUM"
albumId: string
playlistId: string
name: string
artists: ArtistBasic[]
year: number
thumbnails: ThumbnailFull[]
}
```
## Usages
[ArtistFull#topAlbums](./ArtistFull.html)
[SearchResult](../types/SearchResult.html)
[YTMusic#searchAlbums](../ytmusic/searchAlbums.html)
[YTMusic#getArtistAlbums](../ytmusic/getArtistAlbums.html)

View File

@ -0,0 +1,35 @@
# AlbumFull
## Properties
| Name | Data Type | Description |
| :------------ | :---------------------------------------- | :-------------------- |
| `type` | `"ALBUM"` | Type of data |
| `albumId` | `string` | Album ID |
| `playlistId` | `string` | Playlist ID for Album |
| `name` | `string` | Name |
| `artists` | [ArtistBasic](./ArtistBasic.html)`[]` | Creators of the Album |
| `year` | `number` | Publication Year |
| `thumbnails` | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
| `description` | `string` | Description |
| `songs` | [SongDetailed](./SongDetailed.html)`[]` | Songs in the Album |
## TypeScript Source Code
```ts
interface AlbumFull {
type: "ALBUM"
albumId: string
playlistId: string
name: string
artists: ArtistBasic[]
year: number
thumbnails: ThumbnailFull[]
description: string
songs: SongDetailed[]
}
```
## Usages
[YTMusic#getAlbum](../ytmusic/getAlbum.md)

View File

@ -0,0 +1,27 @@
# ArtistBasic
## Properties
| Name | Data Type | Description |
| :------- | :-------- | :---------- |
| artistId | `string` | Artist ID |
| name | `string` | Name |
## TypeScript Source Code
```ts
interface ArtistBasic {
artistId: string
name: string
}
```
## Usages
[SongDetailed#artists](./SongDetailed.html)
[VideoDetailed#artists](./VideoDetailed.html)
[AlbumDetailed#artists](./AlbumDetailed.html)
[PlaylistFull#artist](./PlaylistFull.html)

View File

@ -0,0 +1,27 @@
# ArtistDetailed
## Properties
| Name | Data Type | Description |
| :--------- | :---------------------------------------- | :----------- |
| type | `"ARTIST"` | Type of data |
| artistId | `string` | Artist ID |
| name | `string` | Name |
| thumbnails | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
## TypeScript Source Code
```ts
interface ArtistDetailed {
type: "ARTIST"
artistId: string
name: string
thumbnails: ThumbnailFull[]
}
```
## Usages
[SearchResult](../types/SearchResult.html)
[YTMusic#searchArtists](../ytmusic/searchArtists.html)

View File

@ -0,0 +1,33 @@
# ArtistFull
## Properties
| Name | Data Type | Description |
| :---------- | :---------------------------------------------------------- | :----------------------------------- |
| type | `"ARTIST"` | Type of data |
| artistId | `string` | Artist ID |
| name | `string` | Name |
| thumbnails | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
| description | `string` | Description |
| subscribers | `number` | Number of subscribers the Artist has |
| topSongs | `Omit<`[SongDetailed](./SongDetailed.html)`, "duration">[]` | Top Songs from Artist |
| topAlbums | [AlbumDetailed](./AlbumDetailed.html)`[]` | Top Albums from Artist |
## TypeScript Source Code
```ts
interface ArtistFull {
type: "ARTIST"
artistId: string
name: string
thumbnails: ThumbnailFull[]
description: string
subscribers: number
topSongs: Omit<SongDetailed, "duration">[]
topAlbums: AlbumDetailed[]
}
```
## Usages
[YTMusic#getArtist](../ytmusic/getArtist.html)

View File

@ -0,0 +1,33 @@
# PlaylistFull
## Properties
| Name | Data Type | Description |
| :--------- | :---------------------------------- | :------------------------------- |
| type | `"PLAYLIST"` | Type of data |
| playlistId | `string` | Playlist ID |
| name | `string` | Name |
| artist | [ArtistBasic](#ArtistBasic) | Creator of the Playlist |
| videoCount | `number` | Number of videos in the Playlist |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
## TypeScript Source Code
```ts
interface PlaylistFull {
type: "PLAYLIST"
playlistId: string
name: string
artist: ArtistBasic
videoCount: number
thumbnails: ThumbnailFull[]
}
```
## Usages
[SearchResult](../types/SearchResult.html)
[YTMusic#searchPlaylists](../ytmusic/searchPlaylists.html)
[YTMusic#getPlaylist](../ytmusic/getPlaylist.html)

View File

@ -0,0 +1,39 @@
# SongDetailed
## Properties
| Name | Data Type | Description |
| :--------- | :---------------------------------------- | :------------------ |
| type | `"SONG"` | Type of data |
| videoId | `string` | YouTube Video ID |
| name | `string` | Name |
| artists | [ArtistBasic](./ArtistBasic.html)`[]` | Artists |
| album | [AlbumBasic](./AlbumBasic.html) | Album |
| duration | `number` | Duration in seconds |
| thumbnails | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
## TypeScript Source Code
```ts
interface SongDetailed {
type: "SONG"
videoId: string
name: string
artists: ArtistBasic[]
album: AlbumBasic
duration: number
thumbnails: ThumbnailFull[]
}
```
## Usages
[ArtistFull#topSongs](./ArtistFull.html)
[AlbumFull#songs](./AlbumFull.html)
[SearchResult](../types/SearchResult.html)
[YTMusic#searchSongs](../ytmusic/searchSongs.html)
[YTMusic#getArtistSongs](../ytmusic/getArtistSongs.html)

View File

@ -0,0 +1,35 @@
# SongFull
## Properties
| Name | Data Type | Description |
| :-------------- | :---------------------------------------- | :--------------------- |
| type | `"SONG"` | Type of data |
| videoId | `string` | YouTube Video ID |
| name | `string` | Name |
| artists | [ArtistBasic](./ArtistBasic.html)`[]` | Artists |
| duration | `number` | Duration in seconds |
| thumbnails | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
| description | `string` | Description |
| formats | `any[]` | Video Formats |
| adaptiveFormats | `any[]` | Adaptive Video Formats |
## TypeScript Source Code
```ts
interface SongFull {
type: "SONG"
videoId: string
name: string
artists: ArtistBasic[]
duration: number
thumbnails: ThumbnailFull[]
description: string
formats: any[]
adaptiveFormats: any[]
}
```
## Usages
[YTMusic#getSong](../ytmusic/getSong.html)

View File

@ -0,0 +1,31 @@
# ThumbnailFull
## Properties
| Name | Data Type | Description |
| :------- | :-------- | :------------------ |
| `url` | `string` | Link |
| `width` | `number` | Width of the image |
| `height` | `number` | Height of the image |
## TypeScript Source Code
```ts
interface ThumbnailFull {
url: string
width: number
height: number
}
```
## Usages
[SongDetailed#thumbnails](./SongDetailed.html)
[VideoDetailed#thumbnails](./VideoDetailed.html)
[ArtistDetailed#thumbnails](./ArtistDetailed.html)
[AlbumDetailed#thumbnails](./AlbumDetailed.html)
[PlaylistFull#thumbnails](./PlaylistFull.html)

View File

@ -0,0 +1,35 @@
# VideoDetailed
## Properties
| Name | Data Type | Description |
| :--------- | :---------------------------------------- | :------------------------------ |
| type | `"VIDEO"` | Type of data |
| videoId | `string` | YouTube Video ID |
| name | `string` | Name |
| artists | [ArtistBasic](./ArtistBasic.html)`[]` | Channels that created the video |
| views | `number` | View count |
| duration | `number` | Duration in seconds |
| thumbnails | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
## TypeScript Source Code
```ts
interface VideoDetailed {
type: "VIDEO"
videoId: string
name: string
artists: ArtistBasic[]
views: number
duration: number
thumbnails: ThumbnailFull[]
}
```
## Usages
[SearchResult](../types/SearchResult.html)
[YTMusic#searchVideos](../ytmusic/searchVideos.html)
[YTMusic#getPlaylistVideos](../ytmusic/getPlaylistVideos.html)

View File

@ -0,0 +1,41 @@
# VideoFull
## Properties
| Name | Data Type | Description |
| :---------- | :---------------------------------------- | :------------------------------------- |
| type | `"VIDEO"` | Type of data |
| videoId | `string` | YouTube Video ID |
| name | `string` | Name |
| artists | [ArtistBasic](./ArtistBasic.html)`[]` | Channels that created the video |
| views | `number` | View count |
| duration | `number` | Duration in seconds |
| thumbnails | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
| description | `string` | Description |
| unlisted | `boolean` | If the video is unlisted on YouTube |
| familySafe | `boolean` | If the video is family safe on YouTube |
| paid | `boolean` | If the video is paid on YouTube |
| tags | `string[]` | Tags |
## TypeScript Source Code
```ts
interface VideoFull {
type: "VIDEO"
videoId: string
name: string
artists: ArtistBasic[]
views: number
duration: number
thumbnails: ThumbnailFull[]
description: string
unlisted: boolean
familySafe: boolean
paid: boolean
tags: string[]
}
```
## Usages
[YTMusic#getVideo](../ytmusic/getVideo.html)

3
docs/references/types.md Normal file
View File

@ -0,0 +1,3 @@
# Types
- [SearchResult](../types/SearchResult.html)

View File

@ -0,0 +1,26 @@
# SearchResult
## Value
Either
- [SongDetailed](../interfaces/SongDetailed.html)
- [VideoDetailed](../interfaces/VideoDetailed.html)
- [AlbumDetailed](../interfaces/AlbumDetailed.html)
- [ArtistDetailed](../interfaces/ArtistDetailed.html)
- [PlaylistFull](../interfaces/PlaylistFull.html)
## TypeScript Source Code
```ts
type SearchResult =
| SongDetailed
| VideoDetailed
| AlbumDetailed
| ArtistDetailed
| PlaylistFull
```
## Usages
[YTMusic#search](../ytmusic/search.html)

View File

@ -0,0 +1,19 @@
# YTMusic Class
## Methods
- [getSearchSuggestions](./ytmusic/getSearchSuggestions.html)
- [search](./ytmusic/search.html)
- [searchSongs](./ytmusic/searchSongs.html)
- [searchVideos](./ytmusic/searchVideos.html)
- [searchArtists](./ytmusic/searchArtists.html)
- [searchAlbums](./ytmusic/searchAlbums.html)
- [searchPlaylists](./ytmusic/searchPlaylists.html)
- [getSong](./ytmusic/getSong.html)
- [getVideo](./ytmusic/getVideo.html)
- [getArtist](./ytmusic/getArtist.html)
- [getArtistSongs](./ytmusic/getArtistSongs.html)
- [getArtistAlbums](./ytmusic/getArtistAlbums.html)
- [getAlbum](./ytmusic/getAlbum.html)
- [getPlaylist](./ytmusic/getPlaylist.html)
- [getPlaylistVideos](./ytmusic/getPlaylistVideos.html)

View File

@ -0,0 +1,19 @@
# getAlbum
See the [guide](../../guides/usage/getAlbum.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :-------- | :-------- | :---------- |
| `albumId` | `string` | Album ID |
## Returns
`Promise<`[AlbumFull](../interfaces/AlbumFull.html)`>`
## TypeScript Source Code
```ts
public async getAlbum(albumId: string): Promise<AlbumFull>
```

View File

@ -0,0 +1,19 @@
# getArtist
See the [guide](../../guides/usage/getArtist.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :--------- | :-------- | :---------- |
| `artistId` | `string` | Artist ID |
## Returns
`Promise<`[ArtistFull](../interfaces/ArtistFull.html)`>`
## TypeScript Source Code
```ts
public async getArtist(artistId: string): Promise<ArtistFull>
```

View File

@ -0,0 +1,19 @@
# getArtistAlbums
See the [guide](../../guides/usage/getArtistAlbums.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :--------- | :-------- | :---------- |
| `artistId` | `string` | Artist ID |
## Returns
`Promise<`[AlbumDetailed](../interfaces/AlbumDetailed.html)`[]>`
## TypeScript Source Code
```ts
public async getArtistAlbums(artistId: string): Promise<AlbumDetailed[]>
```

View File

@ -0,0 +1,19 @@
# getArtistSongs
See the [guide](../../guides/usage/getArtistSongs.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :--------- | :-------- | :---------- |
| `artistId` | `string` | Artist ID |
## Returns
`Promise<`[SongDetailed](../interfaces/SongDetailed.html)`[]>`
## TypeScript Source Code
```ts
public async getArtistSongs(artistId: string): Promise<SongDetailed[]>
```

View File

@ -0,0 +1,19 @@
# getPlaylist
See the [guide](../../guides/usage/getPlaylist.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :----------- | :-------- | :---------- |
| `playlistId` | `string` | Playlist ID |
## Returns
`Promise<`[PlaylistFull](../interfaces/PlaylistFull.html)`>`
## TypeScript Source Code
```ts
public async getPlaylist(playlistId: string): Promise<PlaylistFull>
```

View File

@ -0,0 +1,19 @@
# getPlaylistVideos
See the [guide](../../guides/usage/getPlaylistVideos.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :----------- | :-------- | :---------- |
| `playlistId` | `string` | Playlist ID |
## Returns
`Promise<Omit<`[VideoDetailed](../interfaces/VideoDetailed.html)`, "views">[]>`
## TypeScript Source Code
```ts
public async getPlaylistVideos(playlistId: string): Promise<Omit<VideoDetailed, "views">[]>
```

View File

@ -0,0 +1,19 @@
# getSearchSuggestions
See the [guide](../../guides/usage/getSearchSuggestions.html) for information on how to use this.
## Parameters
| Name | Data Type | Description |
| :---- | :-------- | :------------------------------------ |
| query | string | Search query you want suggestions for |
## Returns
`Promise<string[]>`
## TypeScript Source Code
```ts
public async getSearchSuggestions(query: string): Promise<string[]>
```

View File

@ -0,0 +1,19 @@
# getSong
See the [guide](../../guides/usage/getSong.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :-------- | :-------- | :---------- |
| `videoId` | `string` | Video ID |
## Returns
`Promise<`[SongFull](../interfaces/SongFull.html)`>`
## TypeScript Source Code
```ts
public async getSong(videoId: string): Promise<SongFull>
```

View File

@ -0,0 +1,19 @@
# getVideo
See the [guide](../../guides/usage/getVideo.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :-------- | :-------- | :---------- |
| `videoId` | `string` | Video ID |
## Returns
`Promise<`[VideoFull](../interfaces/VideoFull.html)`>`
## TypeScript Source Code
```ts
public async getVideo(videoId: string): Promise<VideoFull>
```

View File

@ -0,0 +1,19 @@
# search
See the [guide](../../guides/usage/search.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :------ | :-------- | :----------- |
| `query` | `string` | Search query |
## Returns
`Promise<`[SearchResult](../types/SearchResult.html)`[]>`
## TypeScript Source Code
```ts
public async search(query: string): Promise<SearchResult[]>
```

View File

@ -0,0 +1,19 @@
# searchAlbums
See the [guide](../../guides/usage/searchAlbums.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :------ | :-------- | :----------- |
| `query` | `string` | Search query |
## Returns
`Promise<`[AlbumDetailed](../interfaces/AlbumDetailed.html)`[]>`
## TypeScript Source Code
```ts
public async searchAlbums(query: string): Promise<AlbumDetailed[]>
```

View File

@ -0,0 +1,19 @@
# searchArtists
See the [guide](../../guides/usage/searchArtists.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :------ | :-------- | :----------- |
| `query` | `string` | Search query |
## Returns
`Promise<`[ArtistDetailed](../interfaces/ArtistDetailed.html)`[]>`
## TypeScript Source Code
```ts
public async searchArtists(query: string): Promise<ArtistDetailed[]>
```

View File

@ -0,0 +1,19 @@
# searchPlaylists
See the [guide](../../guides/usage/searchPlaylists.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :------ | :-------- | :----------- |
| `query` | `string` | Search query |
## Returns
`Promise<`[PlaylistFull](../interfaces/PlaylistFull.html)`[]>`
## TypeScript Source Code
```ts
public async searchPlaylists(query: string): Promise<PlaylistFull[]>
```

View File

@ -0,0 +1,19 @@
# searchSongs
See the [guide](../../guides/usage/searchSongs.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :------ | :-------- | :----------- |
| `query` | `string` | Search query |
## Returns
`Promise<`[SongDetailed](../interfaces/SongDetailed.html)`[]>`
## TypeScript Source Code
```ts
public async searchSongs(query: string): Promise<SongDetailed[]>
```

View File

@ -0,0 +1,19 @@
# searchVideos
See the [guide](../../guides/usage/searchVideos.html) for information on how to use this.
## Properties
| Name | Data Type | Description |
| :------ | :-------- | :----------- |
| `query` | `string` | Search query |
## Returns
`Promise<`[VideoDetailed](../interfaces/VideoDetailed.html)`[]>`
## TypeScript Source Code
```ts
public async searchVideos(query: string): Promise<VideoDetailed[]>
```

View File

@ -11,7 +11,9 @@
"url": "https://github.com/zS1L3NT/ts-npm-ytmusic-api"
},
"scripts": {
"test": "ts-mocha --timeout 30000 src/__tests__/**/*.spec.ts"
"test": "ts-mocha --timeout 30000 src/__tests__/**/*.spec.ts",
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
},
"dependencies": {
"axios": "^0.25.0",
@ -22,10 +24,13 @@
"@types/mocha": "^9.1.0",
"@types/node": "^17.0.23",
"@types/tough-cookie": "^4.0.1",
"@vuepress/plugin-search": "^2.0.0-beta.36",
"mocha": "^9.2.2",
"mocha.parallel": "^0.15.6",
"ts-mocha": "^9.0.2",
"typescript": "^4.5.5"
"typescript": "^4.5.5",
"validate-any": "1.3.1",
"vuepress": "^2.0.0-beta.36"
},
"keywords": [
"youtube",

File diff suppressed because it is too large Load Diff

View File

@ -232,7 +232,7 @@ export default class YTMusic {
*
* @param query Query string
*/
public async searchSong(query: string): Promise<SongDetailed[]> {
public async searchSongs(query: string): Promise<SongDetailed[]> {
const searchData = await this.constructRequest("search", {
query,
params: "Eg-KAQwIARAAGAAgACgAMABqChAEEAMQCRAFEAo%3D"
@ -248,7 +248,7 @@ export default class YTMusic {
*
* @param query Query string
*/
public async searchVideo(query: string): Promise<VideoDetailed[]> {
public async searchVideos(query: string): Promise<VideoDetailed[]> {
const searchData = await this.constructRequest("search", {
query,
params: "Eg-KAQwIABABGAAgACgAMABqChAEEAMQCRAFEAo%3D"
@ -264,7 +264,7 @@ export default class YTMusic {
*
* @param query Query string
*/
public async searchArtist(query: string): Promise<ArtistDetailed[]> {
public async searchArtists(query: string): Promise<ArtistDetailed[]> {
const searchData = await this.constructRequest("search", {
query,
params: "Eg-KAQwIABAAGAAgASgAMABqChAEEAMQCRAFEAo%3D"
@ -280,7 +280,7 @@ export default class YTMusic {
*
* @param query Query string
*/
public async searchAlbum(query: string): Promise<AlbumDetailed[]> {
public async searchAlbums(query: string): Promise<AlbumDetailed[]> {
const searchData = await this.constructRequest("search", {
query,
params: "Eg-KAQwIABAAGAEgACgAMABqChAEEAMQCRAFEAo%3D"
@ -296,7 +296,7 @@ export default class YTMusic {
*
* @param query Query string
*/
public async searchPlaylist(query: string): Promise<PlaylistFull[]> {
public async searchPlaylists(query: string): Promise<PlaylistFull[]> {
const searchData = await this.constructRequest("search", {
query,
params: "Eg-KAQwIABAAGAAgACgBMABqChAEEAMQCRAFEAo%3D"

View File

@ -37,27 +37,27 @@ queries.forEach(query => {
})
it("Search Songs", async () => {
const songs = await ytmusic.searchSong(query)
const songs = await ytmusic.searchSongs(query)
expect(songs, LIST(SONG_DETAILED))
})
it("Search Videos", async () => {
const videos = await ytmusic.searchVideo(query)
const videos = await ytmusic.searchVideos(query)
expect(videos, LIST(VIDEO_DETAILED))
})
it("Search Artists", async () => {
const artists = await ytmusic.searchArtist(query)
const artists = await ytmusic.searchArtists(query)
expect(artists, LIST(ARTIST_DETAILED))
})
it("Search Albums", async () => {
const albums = await ytmusic.searchAlbum(query)
const albums = await ytmusic.searchAlbums(query)
expect(albums, LIST(ALBUM_DETAILED))
})
it("Search Playlists", async () => {
const playlists = await ytmusic.searchPlaylist(query)
const playlists = await ytmusic.searchPlaylists(query)
expect(playlists, LIST(PLAYLIST_FULL))
})
@ -70,49 +70,49 @@ queries.forEach(query => {
})
it("Get details of the first song result", async () => {
const songs = await ytmusic.searchSong(query)
const songs = await ytmusic.searchSongs(query)
const song = await ytmusic.getSong(songs[0]!.videoId)
expect(song, SONG_FULL)
})
it("Get details of the first video result", async () => {
const videos = await ytmusic.searchVideo(query)
const videos = await ytmusic.searchVideos(query)
const video = await ytmusic.getVideo(videos[0]!.videoId)
expect(video, VIDEO_FULL)
})
it("Get details of the first artist result", async () => {
const artists = await ytmusic.searchArtist(query)
const artists = await ytmusic.searchArtists(query)
const artist = await ytmusic.getArtist(artists[0]!.artistId)
expect(artist, ARTIST_FULL)
})
it("Get the songs of the first artist result", async () => {
const artists = await ytmusic.searchArtist(query)
const artists = await ytmusic.searchArtists(query)
const songs = await ytmusic.getArtistSongs(artists[0]!.artistId)
expect(songs, LIST(SONG_DETAILED))
})
it("Get the albums of the first artist result", async () => {
const artists = await ytmusic.searchArtist(query)
const artists = await ytmusic.searchArtists(query)
const albums = await ytmusic.getArtistAlbums(artists[0]!.artistId)
expect(albums, LIST(ALBUM_DETAILED))
})
it("Get details of the first album result", async () => {
const albums = await ytmusic.searchAlbum(query)
const albums = await ytmusic.searchAlbums(query)
const album = await ytmusic.getAlbum(albums[0]!.albumId)
expect(album, ALBUM_FULL)
})
it("Get details of the first playlist result", async () => {
const playlists = await ytmusic.searchPlaylist(query)
const playlists = await ytmusic.searchPlaylists(query)
const playlist = await ytmusic.getPlaylist(playlists[0]!.playlistId)
expect(playlist, PLAYLIST_FULL)
})
it("Get the videos of the first playlist result", async () => {
const playlists = await ytmusic.searchPlaylist(query)
const playlists = await ytmusic.searchPlaylists(query)
const videos = await ytmusic.getPlaylistVideos(playlists[0]!.playlistId)
expect(videos, LIST(PLAYLIST_VIDEO))
})