File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,8 +34,10 @@ import {
3434 parse_mixed_content ,
3535 parse_moods ,
3636 parse_playlist ,
37+ parse_user_contents ,
3738 ParsedAlbum ,
3839 ParsedPlaylist ,
40+ UserContents ,
3941} from "../parsers/browsing.ts" ;
4042import {
4143 parse_playlist_items ,
@@ -466,8 +468,11 @@ export async function get_artist_albums(
466468 return results . map ( ( result : any ) => parse_album ( result [ MTRIR ] ) ) ;
467469}
468470
469- export interface User extends ArtistContents {
471+ export interface User extends UserContents {
470472 name : string ;
473+ songs_on_repeat : {
474+ results : PlaylistItem [ ] ;
475+ } | null ;
471476}
472477
473478export async function get_user (
@@ -483,9 +488,18 @@ export async function get_user(
483488
484489 const user : User = {
485490 name : j ( json , "header.musicVisualHeaderRenderer" , TITLE_TEXT ) ,
486- ...parse_artist_contents ( results ) ,
491+ ...parse_user_contents ( results ) ,
492+ songs_on_repeat : null ,
487493 } ;
488494
495+ if ( "musicShelfRenderer" in results [ 0 ] ) {
496+ const musicShelf = j ( results [ 0 ] , `${ MUSIC_SHELF } ` ) ;
497+
498+ user . songs_on_repeat = {
499+ results : parse_playlist_items ( musicShelf . contents ) ,
500+ } ;
501+ }
502+
489503 return user ;
490504}
491505
Original file line number Diff line number Diff line change @@ -275,6 +275,22 @@ export function parse_categories<
275275 return categories ;
276276}
277277
278+ export function parse_user_contents ( results : any [ ] ) {
279+ const categories_data = {
280+ artists_on_repeat : [ _ ( "artists_on_repeat" ) , parse_related_artist ] ,
281+ playlists_on_repeat : [ _ ( "playlists_on_repeat" ) , parse_playlist ] ,
282+ playlists : [ _ ( "playlists" ) , parse_playlist ] ,
283+ } satisfies CategoryMap ;
284+
285+ return parse_categories ( results , categories_data ) ;
286+ }
287+
288+ export type NonNUllableUserContents = ReturnType < typeof parse_user_contents > ;
289+
290+ export type UserContents = {
291+ [ Key in keyof NonNUllableUserContents ] : NonNUllableUserContents [ Key ] | null ;
292+ } ;
293+
278294export function parse_artist_contents ( results : any [ ] ) {
279295 const categories_data = {
280296 albums : [ _ ( "albums" ) , parse_album ] ,
You can’t perform that action at this time.
0 commit comments