diff --git a/beetsplug/spotify.py b/beetsplug/spotify.py index 1ef85ba9cb..6decdd2c62 100644 --- a/beetsplug/spotify.py +++ b/beetsplug/spotify.py @@ -836,6 +836,7 @@ def _fetch_info( self._log.debug("Total {} tracks", len(items)) items_to_update: list[tuple[Item, str]] = [] + skipped_without_id = 0 for index, item in enumerate(items, start=1): self._log.info( @@ -849,11 +850,20 @@ def _fetch_info( try: spotify_track_id = item.spotify_track_id except AttributeError: + skipped_without_id += 1 self._log.debug("No track_id present for: {}", item) continue items_to_update.append((item, spotify_track_id)) + if skipped_without_id: + # Silence here makes the command look like it worked when it + # actually fetched nothing for those tracks. + self._log.info( + "Skipped {} track(s) without a spotify_track_id.", + skipped_without_id, + ) + if not items_to_update: return diff --git a/docs/changelog.rst b/docs/changelog.rst index 9c8535fd85..b7e77e29f0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -58,6 +58,10 @@ New features Bug fixes ~~~~~~~~~ +- :doc:`plugins/spotify`: ``beet spotifysync`` now prints how many tracks were + skipped because they have no ``spotify_track_id``. Before, that was only a + debug-level message, so the command looked like it succeeded while fetching + nothing. :bug:`7158` - Import: ``duplicate_keys`` that use library field names such as ``mb_albumid`` or ``mb_trackid`` now detect duplicates when a metadata-source match is applied, instead of treating the key as missing. :bug:`7067` diff --git a/test/plugins/test_spotify.py b/test/plugins/test_spotify.py index c360609990..9117d1bb31 100644 --- a/test/plugins/test_spotify.py +++ b/test/plugins/test_spotify.py @@ -524,6 +524,15 @@ def test_fetch_info_writes_before_store(self): assert write_event_index < database_change_index + def test_fetch_info_reports_tracks_without_id(self): + item = self.add_item_fixture(title="Track 1", artist="Artist") + + with self.assertLogs("beets", level="INFO") as captured_logs: + self.spotify._fetch_info(self.lib, [item], write=True, force=True) + + messages = " ".join(captured_logs.output) + assert "Skipped 1 track(s) without a spotify_track_id" in messages + @responses.activate def test_track_audio_features_batch_disables_on_403(self): responses.add(