Incomplete docs

This commit is contained in:
Zechariah Tan 2022-03-29 17:29:36 +08:00
parent 1cd464b9bc
commit bc2b388eae
4 changed files with 198 additions and 1 deletions

View File

@ -29,6 +29,7 @@ export default defineUserConfig<DefaultThemeOptions>({
} }
] ]
} }
] ],
sidebarDepth: 5
} }
}) })

View File

@ -1,3 +1,15 @@
:root { :root {
scroll-behavior: smooth; scroll-behavior: smooth;
} }
.code-left {
padding-right: 0;
}
.code-right {
padding-left: 0;
}
.anchor {
font-size: 0.85rem;
}

View File

@ -24,6 +24,109 @@ public async getSearchSuggestions(query: string): Promise<string[]>
### `search` ### `search`
::: tip Properties
| Name | Data Type | Description |
| :------ | :-------- | :----------- |
| `query` | `string` | Search query |
:::
::: tip Returns
<code class="code-left">Promise<</code>
<a class="anchor" href="#searchresult">SearchResult</a>
<code class="code-right">[]></code>
:::
```ts
public async search(query: string): Promise<SearchResult[]>
```
#### `search` for songs
::: tip Properties
| Name | Data Type | Description |
| :--------- | :--------- | :----------------------------- |
| `query` | `string` | Search query |
| `category` | `"STRING"` | Category of results to receive |
:::
::: tip Returns
<code class="code-left">Promise<</code>
<a class="anchor" href="#songdetailed">SongDetailed</a>
<code class="code-right">[]></code>
:::
```ts
public async search(query: string, category: "SONG"): Promise<SongDetailed[]>
```
#### `search` for videos
::: tip Properties
| Name | Data Type | Description |
| :--------- | :-------- | :----------------------------- |
| `query` | `string` | Search query |
| `category` | `"VIDEO"` | Category of results to receive |
:::
```ts
public async search(query: string, category: "VIDEO"): Promise<VideoDetailed[]>
```
#### `search` for artists
::: tip Properties
| Name | Data Type | Description |
| :--------- | :--------- | :----------------------------- |
| `query` | `string` | Search query |
| `category` | `"ARTIST"` | Category of results to receive |
:::
```ts
public async search(query: string, category: "ARTIST"): Promise<ArtistDetailed[]>
```
#### `search` for albums
::: tip Properties
| Name | Data Type | Description |
| :--------- | :-------- | :----------------------------- |
| `query` | `string` | Search query |
| `category` | `"ALBUM"` | Category of results to receive |
:::
```ts
public async search(query: string, category: "ALBUM"): Promise<AlbumDetailed[]>
```
#### `search` for playlists
::: tip Properties
| Name | Data Type | Description |
| :--------- | :----------- | :----------------------------- |
| `query` | `string` | Search query |
| `category` | `"PLAYLIST"` | Category of results to receive |
:::
```ts
public async search(query: string, category: "PLAYLIST"): Promise<PlaylistFull[]>
```
### `getSong` ### `getSong`
### `getVideo` ### `getVideo`

View File

@ -32,6 +32,87 @@ ytmusic.getSearchSuggestions("Lilac").then(res => {
## `search` function ## `search` function
`search()` will fetch search results from YouTube Music directly based on the query and result type provided
### `search` for songs
### `search` for videos
### `search` for artists
### `search` for albums
### `search` for playlists
This function takes in the following parameters
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` function ## `getSong` function
## `getVideo` function ## `getVideo` function