Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TIDAL autotagger plugin #5637

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

jcjordyn130
Copy link
Contributor

Description

This is a replacement of the last TIDAL PR I opened back in 2023 (#4641), as in, it is a proper autotagger implementation using the TIDAL API.

Candidate retrieval and support for direct TIDAL album and track URLs are supported.

It also fetches lyrics (both time-synced and not), and embeds it into both the file tags and a LRC file if configured.

Adding testing is a little complicated as testing lyrics support requires a paid account, however, basic metadata queries only require an account with or without an active subscription.

I have been using this plugin for about a week now with my library and it seems to be holding up, obtaining lyrics that are otherwise unavailable through the available lyrics backends.

Poetry files were changed to add optional dependencies for this plugin, which are tidalapi, cachetools (for LFU cache in hot functions), and backoff (to slow down queries when rate limited).

Also, please do let me know if you want me to squash my commits, as I know there are quite a few of them.

To Do

  • Documentation
  • Changelog (Will add once change is approved)
  • Tests

Copy link

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

- Initial implementation of LRC writing support
- Split imported file processing to its' own function
- Actually remove the session file instead of blanking it out
- Check for auto status before loading the TIDAL session
- Implement LFUCache on hot functions
- Fix docstrings
- Add backoff handler for debugging
- Add fatal argument to _load_session to throw UserError
- Reduce excessive calls for track metadata retrival
- _search_track now returns tidalapi types and no longer grabs the full album metadata
- Add user configurable result limits for both metadata and lyrics
- tidalapi was changed from a star import to a regular import
- Logic error in _process_item was fixed, was used undefined track
- Fix duplicate track removal from _search_lyrics
- Stop adding top_hit result twice in _search_album and _search_track
- Add output when the login was successful
It was never used and it can always be dumped with a regular `cat` command
- Break out _get_lyrics specific metadata searching algorithm into seperate function (_search_from_metadata)
- Remove _search_album as it is now unused
- Fix candidates function shadowing parameters
- Candidate functions now use _search_from_metadata
- Candidate functions now handle va_likely
The plugin has been operating on the original files this entire time.

Changes:
- Add a write event listener to write out sidecar files
- Remove file management from the import stage, as this is already handled in Item.write()
This currently only works with synced lyrics and needs to be changed if TIDAL ever changes their lyrics format.
- Change _validate_lyrics to use tidalapi Track length instead of calculating length from lyrics
- Change _search_from_metadata to search for alternative artists
- Add config toggle for items with no duration to assume valid lyrics or not
- Change _search_track so queries are stripped of special characters and medium details, as the TIDAL search engine is picky
Technically, Items can have an infinite number of max artists.

Let's add a user-configurable cap to avoid excessive TIDAL API usage.
- Add another implementation of _serach_album
- Remove unused variables from LRC timestamp calculation
- Change candidates function to use _search_album instead of grabbing a new Album instance from _search_track
- Change _search_from_metadata to search for albums as well
- Fix logic errors and unused variables in _validate_lyrics
- Move the initial session load into __init__ as it is called before any of the plugin functions
- Move query fixing into _tidal_search from the respective _search functions
- Reworded UIError message in _load_session
- Ran `poe lint` and fixed all errors
- Ran `poe format`
- Reworded some docstrings to make them shorter
- Split some strings between two lines to avoid going over line length limit
- Move _load_session from __init__ to an import_begin event handler
Turns out, _search_lyrics didn't use its own limit parameter and was directly using self.config.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant