diff --git a/src/YTMusic.ts b/src/YTMusic.ts index 61261fc..b33d851 100644 --- a/src/YTMusic.ts +++ b/src/YTMusic.ts @@ -502,6 +502,11 @@ export default class YTMusic { return songs.map(VideoParser.parsePlaylistVideo) } + /** + * Get content for the home page. + * + * @returns Mixed HomePageContent + */ public async getHome(): Promise { const results: HomePageContent[] = [] const page = await this.constructRequest("browse", { browseId: FE_MUSIC_HOME }) diff --git a/src/parsers/Parser.ts b/src/parsers/Parser.ts index 2a56fa0..05ac2a2 100644 --- a/src/parsers/Parser.ts +++ b/src/parsers/Parser.ts @@ -36,6 +36,16 @@ export default class Parser { } } + /** + * Parses mixed content data into a structured `HomePageContent` object. + * + * This static method takes raw data of mixed content types and attempts to parse it into a + * more structured format suitable for use as home page content. It supports multiple content + * types such as music descriptions, artists, albums, playlists, and songs. + * + * @param {any} data - The raw data to be parsed. + * @returns {HomePageContent | null} A `HomePageContent` object if parsing is successful, or null otherwise. + */ public static parseMixedContent(data: any): HomePageContent | null { const key = Object.keys(data)[0] if (!key) throw new Error("Invalid content")