🐛 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", "name": "ytmusic-api",
"version": "4.0.1", "version": "4.0.2",
"description": "YouTube Music API", "description": "YouTube Music API",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

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