Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get artist singles #47

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

zokiasu
Copy link

@zokiasu zokiasu commented Feb 1, 2025

Add getArtistSingles function

Description

This PR adds a new getArtistSingles function to retrieve the complete list of singles from an artist. While the existing getArtist function only returns top singles, this new function fetches all singles available on the artist's page, similar to how getArtistAlbums works for albums.

Features

  • New getArtistSingles function that returns an array of AlbumDetailed
  • Utilizes the same browsing endpoint as getArtistAlbums
  • Automatically extracts the singles carousel from the artist's page
  • Returns full metadata for each single (name, year, thumbnails, etc.)

Implementation Details

  • Uses the second carousel (index 1) from the artist's page which contains singles
  • Follows the same pattern as getArtistAlbums for consistency
  • Reuses existing AlbumParser.parseArtistAlbum for parsing the response

Testing

  • Added new test case in core.spec.ts
  • Tested with multiple artists (Lilac, Weekend, Eill, Eminem, Lisa Hannigan)
  • All tests pass successfully

Use Case

This function is particularly useful when you need to:

  • Track all singles from an artist, not just the top ones
  • Build a complete discography
  • Monitor new single releases

Example Usage

const ytmusic = new YTMusic();
await ytmusic.initialize();

const artistId = "ARTIST_ID";
const singles = await ytmusic.getArtistSingles(artistId);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant