Skip to content
Closed
Show file tree
Hide file tree
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 beetsplug/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
9 changes: 9 additions & 0 deletions test/plugins/test_spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading