tidal: Add flexible attributes and tidalsync command for popularity data#6744
tidal: Add flexible attributes and tidalsync command for popularity data#6744arsaboo wants to merge 9 commits into
Conversation
- Add item_types ClassVar with tidal_track_id, tidal_album_id, tidal_artist_id, tidal_track_popularity, tidal_alb_popularity, tidal_updated fields - Populate flexattrs during album/track import via AlbumInfo/TrackInfo kwargs - Add beet tidalsync command to refresh popularity data post-import - Add tidal fields to REIMPORT_FRESH_FIELDS_ITEM for reimport support - Add tests for flexattr population and tidalsync behavior - Update tidal plugin docs with attribute reference and tidalsync usage
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6744 +/- ##
==========================================
+ Coverage 74.52% 74.54% +0.01%
==========================================
Files 162 162
Lines 20818 20882 +64
Branches 3295 3315 +20
==========================================
+ Hits 15515 15566 +51
- Misses 4547 4555 +8
- Partials 756 761 +5
🚀 New features to boost your workflow:
|
- Use self.add_item() instead of self.lib.add_item() in tests - Fix mypy: add isinstance(val, int) check in _popularity() - Apply ruff formatting
| duration=self._duration_to_seconds(track["attributes"]["duration"]), | ||
| label=self._parse_label(track["attributes"]), | ||
| # Flexattrs | ||
| tidal_track_id=int(track["id"]), |
There was a problem hiding this comment.
It looks like we're now storing the same track ID twice in the database: track_id and tidal_track_id.
Summoning @snejus ;) What's our preferred approach here? Should we consolidate these?
**same for artist_id
There was a problem hiding this comment.
I am not sure we can consolidate. All the other plugins (bandcamp, spotify, etc. store bandcamp_album_id, spotify_album_id as flexattrs). Until we can make musicbrainz completely optional, I feel we keep them for consistency with the plugin ecosystem pattern (other metadata plugins store their own *_id flexattrs), but we should get @snejus's input.
Also makes queries like tidal_track_id unambiguous without needing to know which standard field maps to which source.
|
Sorry about the iterative comments. Im coming back to this whenever I have time or thought about something ;) I just noticed that albums on tidal also have I'm also able to make some changes if you feel like it gets too much give me a headsup 😨 |
…d album popularity to sync
We have Please don't worry about it. Happy to work with you on this and get this merged. Thanks for all your guidance, and by all means, feel free to improve upon it. |
Im not entirely sure how the best UX should look like here tbh. Both variants (with and without prefix) come with tradeoffs 🤔 |
We are not currently exposing popularity information in UI. This is mostly for the DB so that we can use it for other smart things (playlists) |
I mean the query syntax with UX. The question is whether users should have separate fields per entity, such as: beet ls tidal_album_popularity:5..20or a single generic field whose meaning depends on the search scope, for example: The latter is shorter and more flexible, but the former is more explicit and consistent across entity types. |
I would (strongly) prefer the former, just to be explicit. |
Replace tidalsync() with sync_item_popularity() / sync_album_popularity() backed by a shared _sync_popularity() helper. Split the `tidal` command into `tidal` (auth-only) and `tidalsync` (popularity sync with --item, --album, --force, --write flags). While I liked the tidal [auth|sync] it is currently not well supported in beets and e.g. help pages are lacking. Accept int IDs throughout the search pipeline to avoid unnecessary str conversions.
|
@arsaboo Just enhanced the sync logic a bit. Make sure to pull ;) Please have a look! Am mostly happy with the changes but ofcourse if you see something or have a better idea, lets discuss. |
This PR adds six typed flexible attributes to the Tidal plugin that are populated during album/track imports, and introduces a new
beet tidalsynccommand to refresh popularity data post-import.cc: @semohr
Flexible Attributes (
item_types)tidal_track_id,tidal_album_id,tidal_artist_id— INTEGER fields for Tidal entity IDs.tidal_track_popularity,tidal_alb_popularity— INTEGER (0–100) normalized popularity scores.tidal_updated— DATE timestamp of last sync.Import population
_get_album_info()and_get_track_info()pass the new fields through toAlbumInfo/TrackInfo, which store them as flexattrs on the item._popularity()helper normalizes float/int/None from the Tidal API.Reimport support
REIMPORT_FRESH_FIELDS_ITEMso they refresh on reimport.beet tidalsynccommandtidal_track_id, and updatestidal_track_popularity+tidal_updated.--force/-f— re-fetch even if data already exists.--write/-w— write updated tags to media files.beet tidalsync artist:Miles).Documentation & Tests
Attribute reference table and command usage examples in
docs/plugins/tidal.rst.Flexattr assertions in existing tests, new
TestPopularityandTestTidalsynctest classes.Documentation. (If you've added a new command-line flag, for example, find the appropriate page under
docs/to describe it.)Changelog. (Add an entry to
docs/changelog.rstto the bottom of one of the lists near the top of the document.)Tests. (Very much encouraged but not strictly required.)