Skip to content

feat(server): add option Lastfm.ScrobbleFirstArtistOnly to send only the first artist #4131

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

Merged
merged 1 commit into from
May 28, 2025

Conversation

deluan
Copy link
Member

@deluan deluan commented May 28, 2025

This pull request introduces a new configuration option, ScrobbleFirstArtistOnly, for Last.fm integration. The option allows users to specify whether only the first listed artist should be scrobbled for tracks with multiple artists. The changes include updates to configuration handling, the Last.fm agent logic, and associated tests.

Configuration Updates:

  • Added a new field, ScrobbleFirstArtistOnly, to the lastfmOptions struct in conf/configuration.go to support the new configuration option.
  • Set the default value for ScrobbleFirstArtistOnly to false in the setViperDefaults function.

Last.fm Agent Logic:

  • Introduced a new method, getArtistForScrobble, in core/agents/lastfm/agent.go to determine the artist to scrobble based on the ScrobbleFirstArtistOnly configuration. Updated the NowPlaying and Scrobble methods to use this logic. [1] [2]

Tests:

  • Updated the lastfmAgent test setup in core/agents/lastfm/agent_test.go to include multiple artists in the Participants field of the test track.
  • Added a test case to verify that the ScrobbleFirstArtistOnly configuration correctly scrobbles only the first artist when enabled.

fixes #3791

…y the first artist

fixes #3791

Signed-off-by: Deluan <deluan@navidrome.org>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @deluan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

Hello! Gemini here, providing a summary of this pull request. This PR introduces a new configuration option for the Last.fm integration: Lastfm.ScrobbleFirstArtistOnly. The purpose of this option is to give users control over how tracks with multiple artists are scrobbled. When enabled, only the first artist listed for a track will be sent to Last.fm, rather than the potentially concatenated list or primary artist field. This change involves adding the configuration field, setting its default value, modifying the Last.fm agent logic to respect the new setting, and adding corresponding tests. This work directly addresses issue #3791.

Highlights

  • New Last.fm Configuration Option: A new boolean configuration option, Lastfm.ScrobbleFirstArtistOnly, has been added to control whether only the first artist is used when scrobbling tracks with multiple artists. The default value is set to false.
  • Last.fm Agent Logic Update: A new helper function getArtistForScrobble was introduced in the Last.fm agent. This function checks the new configuration option and the track's participant list to determine the correct artist name to use for both 'Now Playing' updates and scrobbles. The NowPlaying and Scrobble methods were updated to utilize this new function.
  • Testing for New Configuration: The Last.fm agent tests were updated to include tracks with multiple artists in the test setup. A new test case was added specifically to verify that when ScrobbleFirstArtistOnly is enabled, the agent correctly sends only the first artist's name during scrobbling.

Changelog

  • conf/configuration.go
    • Added ScrobbleFirstArtistOnly bool field to the lastfmOptions struct (line 161).
    • Set the default value for lastfm.scrobblefirstartistonly to false in setViperDefaults (line 532).
  • core/agents/lastfm/agent.go
    • Added a new function getArtistForScrobble to determine the artist based on the new configuration and track participants (lines 282-286).
    • Updated the NowPlaying method to use l.getArtistForScrobble(track) for the artist name (line 296).
    • Updated the Scrobble method to use l.getArtistForScrobble(&s.MediaFile) for the artist name (line 322).
  • core/agents/lastfm/agent_test.go
    • Updated the test track definition to include a Participants map with multiple artists for the RoleArtist (lines 199-204).
    • Added a new When block and It test case to verify scrobbling behavior when ScrobbleFirstArtistOnly is true, asserting that only the 'First Artist' is sent (lines 256-270).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Scrobble sends the tune,
Artist names beneath the moon,
One or many sent.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new configuration option, ScrobbleFirstArtistOnly, for Last.fm integration. The option allows users to specify whether only the first listed artist should be scrobbled for tracks with multiple artists. The changes include updates to configuration handling, the Last.fm agent logic, and associated tests. Overall, this is a solid contribution.

Summary of Findings

  • Artist string source for scrobbling: The getArtistForScrobble method correctly implements the new feature. However, when ScrobbleFirstArtistOnly is false and multiple artists are present in track.Participants, the system relies on track.Artist. It's worth considering if, in this scenario, the artist string should be derived directly from track.Participants to ensure the most complete information is scrobbled, assuming track.Participants is the canonical source.

Merge Readiness

The pull request is well-implemented and adds a useful feature. The new tests cover the functionality effectively. There is one medium-severity point raised for discussion regarding the source of the artist string when scrobbling multiple artists and the new option is disabled. Addressing or clarifying this point would be beneficial. I am unable to approve pull requests myself, but I recommend discussing this point before merging. If the current behavior of relying on track.Artist in that specific case is confirmed as intended, the PR is otherwise in good shape.

@deluan deluan merged commit d4a0533 into master May 28, 2025
35 checks passed
@deluan deluan deleted the scrobblefirstartistonly branch May 28, 2025 12:43
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.

[Bug]: Scrobbles for songs with multiple artists split via separator being handled incorrectly.
1 participant