🐛 fix no albums bug

This commit is contained in:
Zechariah 2022-12-29 10:19:02 +08:00
parent be872ecf5b
commit d60878c8ac
2 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "ytmusic-api",
"version": "4.0.1",
"version": "4.0.2",
"description": "YouTube Music API",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -1,5 +1,6 @@
import { ArtistBasic, ArtistDetailed, ArtistFull } from "../schemas"
import checkType from "../utils/checkType"
import traverse from "../utils/traverse"
import traverseList from "../utils/traverseList"
import traverseString from "../utils/traverseString"
import AlbumParser from "./AlbumParser"
@ -23,11 +24,12 @@ export default class ArtistParser {
topSongs: traverseList(data, "musicShelfRenderer", "contents").map(item =>
SongParser.parseArtistTopSong(item, artistBasic)
),
topAlbums: traverseList(data, "musicCarouselShelfRenderer")
.at(0)
.contents.map((item: any) =>
topAlbums:
traverseList(data, "musicCarouselShelfRenderer")
?.at(0)
?.contents.map((item: any) =>
AlbumParser.parseArtistTopAlbums(item, artistBasic)
)
) ?? []
},
ArtistFull
)