Skip to content

[BUG] Lyrics fetch exception cascades and silently aborts all Tidal track downloads #959

@andrewle8

Description

@andrewle8

Describe the bug

On streamrip 2.2.0, downloading any Tidal album silently produces zero audio files (only cover.jpg lands) when the GET /tracks/{id}/lyrics endpoint returns a non-2xx response. Every track is logged as Error downloading track: 401, message='Unauthorized', url='…/lyrics…' and the actual audio fetch is never attempted. The bug is not tied to any specific album — it reproduces on every Tidal album as long as the lyrics endpoint returns an HTTP error for that track.

The root cause is streamrip/client/tidal.py at the elif media_type == "track": branch around line 113–128:

elif media_type == "track":
    try:
        resp = await self._api_request(
            f"tracks/{item_id!s}/lyrics", base="https://listen.tidal.com/v1"
        )
        ...
    except TypeError as e:
        logger.warning(f"Failed to get lyrics for {item_id}: {e}")

_api_request calls resp.raise_for_status() (line 358), which raises aiohttp.ClientResponseError for 4xx/5xx — not TypeError. The narrow except TypeError lets the ClientResponseError escape, pending.resolve() fails, and media/album.py:40-41 swallows it as "Error downloading track: <err>" without ever calling track.rip(). The lyrics endpoint is currently returning 401 for me (with a freshly-issued device-auth token whose scope is r_usr w_sub w_usr) so every track in every album aborts.

This is similar to #866 (which reports a different underlying error — TypeError: not all arguments converted during string formatting — in the same code path also blocking album downloads). Both point at the same root issue: lyrics are non-essential metadata and should never be able to abort a track download.

Command Used

rip --no-db --folder /tmp/test --quality 3 url "https://tidal.com/browse/album/<any-tidal-album-id>"

Reproduction

  1. streamrip 2.2.0 installed via pipx install --force "streamrip @ git+https://github.com/nathom/streamrip.git@v2.2.0"
  2. Fresh Tidal device auth (clear access_token, refresh_token, token_expiry in the [tidal] section of config, run any rip url command, complete the login flow at the printed link.tidal.com/... URL)
  3. Run the command again after auth completes against any Tidal album URL
  4. Result: the album folder contains only cover.jpg, no .flac files, one ERROR Error downloading track: 401 log line per track referencing …/tracks/{track_id}/lyrics?limit=100&countryCode=US

Expected behavior

Lyrics fetch failure should log a warning and continue with the download. The audio download should succeed independently of lyrics availability.

Proposed fix

Broaden the exception handler in streamrip/client/tidal.py:

-    except TypeError as e:
+    except Exception as e:
         logger.warning(f"Failed to get lyrics for {item_id}: {e}")

I've applied this one-line patch locally and every track of the reproducing album now downloads correctly as FLAC. This should also fix #866 as a side effect, since TypeError is a subclass of Exception.

Happy to send a PR if useful.

Debug Traceback

           ERROR    Error downloading track: 401,                    album.py:41
                    message='Unauthorized',
                    url='…/v1/tracks/{track_id}/lyrics?limit=100&countryCode=US'
(one line per track in the album)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions