Skip to content

Commit

Permalink
add rank and change to playlistitem
Browse files Browse the repository at this point in the history
  • Loading branch information
vixalien committed May 4, 2023
1 parent 779e742 commit ec756e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions parsers/browsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"),
Expand Down
8 changes: 8 additions & 0 deletions parsers/playlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down

0 comments on commit ec756e2

Please sign in to comment.