Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions foobar2000/foo_mac_scrobble/play_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class scrobble_callback : public play_callback_static
if (!(m_length > 0.0 && std::isfinite(m_length)))
{
console::print("Last.fm Scrobbler: Track length invalid or missing, skipping.");
// Clear current track data to prevent re-scrobbling when switching to streams
m_current_track = LastfmApi::TrackInfo();
m_scrobbled = false;
m_threshold = 0;
return;
}

Expand Down Expand Up @@ -132,6 +136,10 @@ class scrobble_callback : public play_callback_static
if (!cfg_enabled.get() || m_scrobbled || p_time < m_threshold)
return;

// Don't scrobble if current track data is empty (e.g., after switching to radio streams)
if (m_current_track.artist.empty() || m_current_track.track.empty())
return;

try
{
static_api_ptr_t<playback_control> playback_control;
Expand Down Expand Up @@ -175,6 +183,8 @@ class scrobble_callback : public play_callback_static
m_scrobbled = false;
m_length = 0;
m_threshold = 0;
// Clear current track data to prevent stale data from being used
m_current_track = LastfmApi::TrackInfo();
}

void on_playback_pause(bool p_state) override
Expand Down