tidal: Add flexible attributes and tidalsync command for popularity data#6744
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.61% 74.68% +0.06%
==========================================
Files 163 163
Lines 20852 20893 +41
Branches 3289 3294 +5
==========================================
+ Hits 15559 15603 +44
+ Misses 4540 4536 -4
- Partials 753 754 +1
🚀 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
This comment was marked as outdated.
This comment was marked as outdated.
…d album popularity to sync
This comment was marked as resolved.
This comment was marked as resolved.
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. |
|
@semohr Excellent. Updated the other parts of the code. Everything is green. |
|
Neat I will have another iteration at it tomorrow. Mainly tests and docs as I have not checked these in detail yet but than we should be good to go 👍 |
semohr
left a comment
There was a problem hiding this comment.
Lets get rid of the unrelated changes please 😆
Most of the changes are to prevent the build from failing. Notice they are material changes, just reorganization to ensure that line length is less than 80. |
|
@arsaboo are you going to undo unrelated changes or shall I commit that instead? |
It will be great if you can do it. I am stepping out for a few and will complete the remaining issues. |
…more refactoring to be consistent.
|
Thanks for the discussions and progress here! |
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.)