diff --git a/parsers/browsing.ts b/parsers/browsing.ts index 3107c3a..e58d7a4 100644 --- a/parsers/browsing.ts +++ b/parsers/browsing.ts @@ -514,7 +514,7 @@ export function parse_video(result: any): ParsedVideo { }; } -type TrendChange = "up" | "down" | "new"; +export type TrendChange = "UP" | "DOWN" /* | "NEW" */ | "NEUTRAL"; export interface TopSong { title: string; @@ -548,7 +548,7 @@ export function parse_top_song(result: any): TopSong { playlistId: jo(title_run, NAVIGATION_PLAYLIST_ID), thumbnails: j(result, THUMBNAILS), rank: j(rank, TEXT_RUN_TEXT), - change: jo(rank, "icon.iconType")?.split("_")[2].toLowerCase() || null, + change: jo(rank, "icon.iconType")?.split("_")[2] || null, album: album_run ? { title: j(album_run, "text"), diff --git a/parsers/playlists.ts b/parsers/playlists.ts index 69c18c1..44c1e68 100644 --- a/parsers/playlists.ts +++ b/parsers/playlists.ts @@ -6,10 +6,12 @@ import { MRLIR, NAVIGATION_VIDEO_TYPE, PLAY_BUTTON, + TEXT_RUN_TEXT, THUMBNAILS, TOGGLE_MENU, } from "../nav.ts"; import { j, jo } from "../util.ts"; +import { TrendChange } from "./browsing.ts"; import { Album, LikeStatus, @@ -46,6 +48,8 @@ export interface PlaylistItem { setVideoId: string | null; feedbackTokens: MenuTokens | null; feedbackToken: null; + rank: string | null; + change: TrendChange | null; } export const parse_playlist_items = ( @@ -136,6 +140,8 @@ export const parse_playlist_items = ( `${MENU_ITEMS}[0].menuNavigationItemRenderer.navigationEndpoint.${NAVIGATION_VIDEO_TYPE}`, ); + const rank = jo(data, "customIndexColumn.musicCustomIndexColumnRenderer"); + const song: PlaylistItem = { videoId, title, @@ -151,6 +157,8 @@ export const parse_playlist_items = ( setVideoId: null, feedbackTokens: null, feedbackToken: null, + rank: rank ? j(rank, TEXT_RUN_TEXT) : null, + change: jo(rank, "icon.iconType")?.split("_")[2] || null, }; if (duration) {