Skip to content

Commit efb1779

Browse files
author
zS1L3NT Windows
committed
🔖 4.3.0
add back video count only to PlaylistFull
1 parent 57c1c37 commit efb1779

File tree

14 files changed

+71
-16
lines changed

14 files changed

+71
-16
lines changed

‎docs/.vuepress/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ export default defineUserConfig({
226226
text: "AlbumFull",
227227
link: "/references/interfaces/AlbumFull.html"
228228
},
229+
{
230+
text: "PlaylistDetailed",
231+
link: "/references/interfaces/PlaylistDetailed.html"
232+
},
229233
{
230234
text: "PlaylistFull",
231235
link: "/references/interfaces/PlaylistFull.html"

‎docs/references/interfaces.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
- [AlbumBasic](./interfaces/AlbumBasic.html)
1212
- [AlbumDetailed](./interfaces/AlbumDetailed.html)
1313
- [AlbumFull](./interfaces/AlbumFull.html)
14+
- [PlaylistDetailed](./interfaces/PlaylistDetailed.html)
1415
- [PlaylistFull](./interfaces/PlaylistFull.html)

‎docs/references/interfaces/ArtistBasic.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ interface ArtistBasic {
2424

2525
[AlbumDetailed#artists](./AlbumDetailed.html)
2626

27+
[PlaylistDetailed#artist](./PlaylistDetailed.html)
28+
2729
[PlaylistFull#artist](./PlaylistFull.html)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# PlaylistDetailed
2+
3+
## Properties
4+
5+
| Name | Data Type | Description |
6+
| :--------- | :---------------------------------- | :------------------------------- |
7+
| type | `"PLAYLIST"` | Type of data |
8+
| playlistId | `string` | Playlist ID |
9+
| name | `string` | Name |
10+
| artist | [ArtistBasic](#ArtistBasic) | Creator of the Playlist |
11+
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
12+
13+
## TypeScript Source Code
14+
15+
```ts
16+
interface PlaylistDetailed {
17+
type: "PLAYLIST"
18+
playlistId: string
19+
name: string
20+
artist: ArtistBasic
21+
thumbnails: ThumbnailFull[]
22+
}
23+
```
24+
25+
## Usages
26+
27+
[SearchResult](../types/SearchResult.html)
28+
29+
[YTMusic#searchPlaylists](../ytmusic/searchPlaylists.html)

‎docs/references/interfaces/PlaylistFull.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
| playlistId | `string` | Playlist ID |
99
| name | `string` | Name |
1010
| artist | [ArtistBasic](#ArtistBasic) | Creator of the Playlist |
11+
| videoCount | `number` | Number of videos in the Playlist |
1112
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
1213

1314
## TypeScript Source Code
@@ -18,14 +19,11 @@ interface PlaylistFull {
1819
playlistId: string
1920
name: string
2021
artist: ArtistBasic
22+
videoCount: number
2123
thumbnails: ThumbnailFull[]
2224
}
2325
```
2426

2527
## Usages
2628

27-
[SearchResult](../types/SearchResult.html)
28-
29-
[YTMusic#searchPlaylists](../ytmusic/searchPlaylists.html)
30-
3129
[YTMusic#getPlaylist](../ytmusic/getPlaylist.html)

‎docs/references/interfaces/ThumbnailFull.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ interface ThumbnailFull {
2828

2929
[AlbumDetailed#thumbnails](./AlbumDetailed.html)
3030

31+
[PlaylistDetailed#thumbnails](./PlaylistDetailed.html)
32+
3133
[PlaylistFull#thumbnails](./PlaylistFull.html)

‎docs/references/types/SearchResult.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Either
88
- [VideoDetailed](../interfaces/VideoDetailed.html)
99
- [AlbumDetailed](../interfaces/AlbumDetailed.html)
1010
- [ArtistDetailed](../interfaces/ArtistDetailed.html)
11-
- [PlaylistFull](../interfaces/PlaylistFull.html)
11+
- [PlaylistDetailed](../interfaces/PlaylistDetailed.html)
1212

1313
## TypeScript Source Code
1414

@@ -18,7 +18,7 @@ type SearchResult =
1818
| VideoDetailed
1919
| AlbumDetailed
2020
| ArtistDetailed
21-
| PlaylistFull
21+
| PlaylistDetailed
2222
```
2323
2424
## Usages

‎docs/references/ytmusic/searchPlaylists.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ See the [guide](../../guides/usage/searchPlaylists.html) for information on how
1010

1111
## Returns
1212

13-
`Promise<`[PlaylistFull](../interfaces/PlaylistFull.html)`[]>`
13+
`Promise<`[PlaylistDetailed](../interfaces/PlaylistDetailed.html)`[]>`
1414

1515
## TypeScript Source Code
1616

1717
```ts
18-
public async searchPlaylists(query: string): Promise<PlaylistFull[]>
18+
public async searchPlaylists(query: string): Promise<PlaylistDetailed[]>
1919
```

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ytmusic-api",
3-
"version": "4.2.0",
3+
"version": "4.3.0",
44
"description": "YouTube Music API",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

‎src/YTMusic.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
AlbumFull,
1414
ArtistDetailed,
1515
ArtistFull,
16+
PlaylistDetailed,
1617
PlaylistFull,
1718
SearchResult,
1819
SongDetailed,
@@ -305,7 +306,7 @@ export default class YTMusic {
305306
*
306307
* @param query Query string
307308
*/
308-
public async searchPlaylists(query: string): Promise<z.infer<typeof PlaylistFull>[]> {
309+
public async searchPlaylists(query: string): Promise<z.infer<typeof PlaylistDetailed>[]> {
309310
const searchData = await this.constructRequest("search", {
310311
query,
311312
params: "Eg-KAQwIABAAGAAgACgBMABqChAEEAMQCRAFEAo%3D",

‎src/__tests__/traversing.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
AlbumFull,
88
ArtistDetailed,
99
ArtistFull,
10+
PlaylistDetailed,
1011
PlaylistFull,
1112
SongDetailed,
1213
SongFull,
@@ -57,7 +58,7 @@ queries.forEach(query => {
5758

5859
it("Search Playlists", async () => {
5960
const playlists = await ytmusic.searchPlaylists(query)
60-
expect(playlists, z.array(PlaylistFull))
61+
expect(playlists, z.array(PlaylistDetailed))
6162
})
6263

6364
it("Search All", async () => {
@@ -66,7 +67,7 @@ queries.forEach(query => {
6667
results,
6768
z.array(
6869
AlbumDetailed.or(ArtistDetailed)
69-
.or(PlaylistFull)
70+
.or(PlaylistDetailed)
7071
.or(SongDetailed)
7172
.or(VideoDetailed),
7273
),

‎src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type {
77
ArtistBasic,
88
ArtistDetailed,
99
ArtistFull,
10+
PlaylistDetailed,
1011
PlaylistFull,
1112
SearchResult,
1213
SongDetailed,

‎src/parsers/PlaylistParser.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PlaylistFull } from "../schemas"
1+
import { PlaylistDetailed, PlaylistFull } from "../schemas"
22
import checkType from "../utils/checkType"
33
import traverseList from "../utils/traverseList"
44
import traverseString from "../utils/traverseString"
@@ -14,13 +14,19 @@ export default class PlaylistParser {
1414
artistId: traverseString(data, "header", "subtitle", "browseId")(),
1515
name: traverseString(data, "header", "subtitle", "text")(2),
1616
},
17+
videoCount:
18+
+traverseList(data, "header", "secondSubtitle", "text")
19+
.at(2)
20+
.split(" ")
21+
.at(0)
22+
.replaceAll(",", "") ?? null,
1723
thumbnails: traverseList(data, "header", "thumbnails"),
1824
},
1925
PlaylistFull,
2026
)
2127
}
2228

23-
public static parseSearchResult(item: any): PlaylistFull {
29+
public static parseSearchResult(item: any): PlaylistDetailed {
2430
const flexColumns = traverseList(item, "flexColumns")
2531

2632
return checkType(
@@ -34,7 +40,7 @@ export default class PlaylistParser {
3440
},
3541
thumbnails: traverseList(item, "thumbnails"),
3642
},
37-
PlaylistFull,
43+
PlaylistDetailed,
3844
)
3945
}
4046
}

‎src/schemas.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ export const AlbumDetailed = z.object({
5959
thumbnails: z.array(ThumbnailFull),
6060
})
6161

62+
export type PlaylistDetailed = z.infer<typeof PlaylistDetailed>
63+
export const PlaylistDetailed = z.object({
64+
type: z.literal("PLAYLIST"),
65+
playlistId: z.string(),
66+
name: z.string(),
67+
artist: ArtistBasic,
68+
thumbnails: z.array(ThumbnailFull),
69+
})
70+
6271
export type SongFull = z.infer<typeof SongFull>
6372
export const SongFull = z.object({
6473
type: z.literal("SONG"),
@@ -119,11 +128,12 @@ export const PlaylistFull = z.object({
119128
playlistId: z.string(),
120129
name: z.string(),
121130
artist: ArtistBasic,
131+
videoCount: z.number(),
122132
thumbnails: z.array(ThumbnailFull),
123133
})
124134

125135
export type SearchResult = z.infer<typeof SearchResult>
126136
export const SearchResult = SongDetailed.or(VideoDetailed)
127137
.or(AlbumDetailed)
128138
.or(ArtistDetailed)
129-
.or(PlaylistFull)
139+
.or(PlaylistDetailed)

0 commit comments

Comments
 (0)