Skip to content

lyrics: Add TIDAL backend#4641

Closed
jcjordyn130 wants to merge 5 commits intobeetbox:masterfrom
jcjordyn130:master
Closed

lyrics: Add TIDAL backend#4641
jcjordyn130 wants to merge 5 commits intobeetbox:masterfrom
jcjordyn130:master

Conversation

@jcjordyn130
Copy link
Copy Markdown
Contributor

@jcjordyn130 jcjordyn130 commented Jan 20, 2023

Description

This adds a TIDAL backend to the lyrics plugin. It requires a paid TIDAL account as the free account returns 404 upon lyrics query. This feature adds a new (optional) dependency on tidalapi though. The lyrics tests completed successfully both in my personal usage and when running the test_lyrics.py file. The reasoning behind this new feature is that TIDAL lyrics have time codes (important for my usage, lyrics in the Navidrome web player require them).

To Do

  • Documentation. (If you've add a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst near the top of the document.)
  • Tests. (Encouraged but not strictly required.)

@jcjordyn130 jcjordyn130 marked this pull request as draft January 23, 2023 01:00
@jcjordyn130 jcjordyn130 marked this pull request as ready for review January 23, 2023 01:17
@sampsyo sampsyo added needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." review-needed and removed needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." labels May 21, 2023
Comment thread beetsplug/lyrics.py

while True:
try:
lyrics = top_hit.lyrics()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this indentation correct?

Comment thread beetsplug/lyrics.py
break
except requests.exceptions.HTTPError as e:
if e.response.status_code == 404:
return None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

may be a debug log here

@arsaboo
Copy link
Copy Markdown
Contributor

arsaboo commented May 25, 2023

I don't have a paid Tidal account to test this, but the code looks fine to me (some minor comments).

I just checked and the free version works for albums/tracks search. It may be a good idea to also create an auto-tag plugin for Tidal (which can work with a free account). Lyrics can then be easily added.

Comment thread beetsplug/lyrics.py
super().__init__(config, log)
self._log = log

sessionfile = self.config["tidal_session_file"].get(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The session file doesn't have to be user-configurable. We can just save something like tidal.json in the config folder.

Comment thread beetsplug/lyrics.py

self.session = self.load_session(sessionfile)

self.attempts = self.config["tidal_attempts"].get(int)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add default values so that these fields can be made optional in the config.

@arsaboo
Copy link
Copy Markdown
Contributor

arsaboo commented May 25, 2023

To future-proof this, we should have a separate tidal config. In the lyrics config, users can then enable tidal by adding it as an additional source.

@stale
Copy link
Copy Markdown

stale Bot commented Oct 15, 2023

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the stale label Oct 15, 2023
@jcjordyn130
Copy link
Copy Markdown
Contributor Author

I don't have a paid Tidal account to test this, but the code looks fine to me (some minor comments).

I just checked and the free version works for albums/tracks search. It may be a good idea to also create an auto-tag plugin for Tidal (which can work with a free account). Lyrics can then be easily added.

So what you're saying is, instead of writing a Lyrics backend, write a metadata source instead?

Would that handle its own lyrics as an import stage hook or would it require modification to the Lyrics plugin to integrate into the new metadata source?

@jcjordyn130 jcjordyn130 mentioned this pull request Feb 18, 2025
3 tasks
@jcjordyn130
Copy link
Copy Markdown
Contributor Author

This PR is based off of a 3 year old commit and requires a lot of work to rebase, additionally, it has also been superseded by #5637.

Closing.

@snejus snejus added the lyrics lyrics plugin label Apr 5, 2026
@semohr semohr mentioned this pull request Apr 11, 2026
5 tasks
semohr added a commit that referenced this pull request Apr 20, 2026
## Description

This PR introduces tidal as metadatasource. It add both an minimal api
layer and the typical metadata source plugin capabilities.

### Details

The implementation provides a small API layer consisting of `TidalAPI`
for high-level album and track fetching, and `TidalSession` which
extends `requests.Session` with token authentication, automatic rate
limiting (~4 req/s via `RateLimitAdapter`), and pagination resolution
following the JSON:API spec.

Authentication is handled through an OAuth2 PKCE flow accessible via
`beet tidal --auth`, with automatic token refresh when the access token
expires.

Metadata parsing handles Tidal's JSON:API response format, extracting
album and track information including ISO 8601 duration conversion,
artist relationships, and copyright/label data.

## Input wanted

The API layer currently lacks comprehensive test coverage. Setting up
proper tests would require either mocking all outgoing requests or
creating a dedicated test token (which necessitates an account and might
require read/write to github secrets).

Are we comfortable with the current approach of unit testing the plugin
itself while mocking all requests?

## TODOs

- [x] Documentation
- [x] `candidate` and `item_candidates` lookup
- [x] It should be possible to optimize batched lookups
- [x] Add tests for candidates and item_candidates
- [x] Implement batching for more than 20 filters


## Refs

thanks to @jcjordyn130 for his initial implementations in #5637 and
#4641
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lyrics lyrics plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants