From 1efbef6f49237de7bd8ab89f56e65fcf80c7bdd2 Mon Sep 17 00:00:00 2001 From: LuanRT Date: Fri, 17 Jun 2022 16:32:13 -0300 Subject: [PATCH] chore(ytmusic): simplify home feed --- lib/parser/contents/classes/MusicCarouselShelf.js | 8 ++++++-- lib/parser/ytmusic/HomeFeed.js | 8 ++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/parser/contents/classes/MusicCarouselShelf.js b/lib/parser/contents/classes/MusicCarouselShelf.js index 46734051..5ff6cc58 100644 --- a/lib/parser/contents/classes/MusicCarouselShelf.js +++ b/lib/parser/contents/classes/MusicCarouselShelf.js @@ -8,8 +8,12 @@ class MusicCarouselShelf { constructor(data) { this.header = Parser.parse(data.header); this.contents = Parser.parse(data.contents); - this.item_size = data.itemSize || null; - this.num_items_per_column = data.numItemsPerColumn || null; + + data.itemSize && + (this.item_size = data.itemSize); + + data.numItemsPerColumn && + (this.num_items_per_column = data.numItemsPerColumn); } } diff --git a/lib/parser/ytmusic/HomeFeed.js b/lib/parser/ytmusic/HomeFeed.js index 9906d312..756cbe86 100644 --- a/lib/parser/ytmusic/HomeFeed.js +++ b/lib/parser/ytmusic/HomeFeed.js @@ -18,15 +18,11 @@ class HomeFeed { this.#page = Parser.parseResponse(response.data); const tab = this.#page.contents.tabs.get({ title: 'Home' }); - const section_list = tab.content?.contents || this.#page.continuation_contents.contents; this.#continuation = tab.content?.continuation || this.#page.continuation_contents.continuation; - /** @type {{ sections: { header: import('../contents/classes/MusicCarouselShelfBasicHeader'), items: object[] }[] }} */ - this.sections = observe(section_list.map((shelf) => ({ - header: shelf.header, - items: shelf.contents - }))); + /** @type {import('../contents/classes/MusicCarouselShelf')[]} */ + this.sections = tab.content?.contents || this.#page.continuation_contents.contents; } /**