Skip to content

New logic, CLI and playlist update for the import script

Quentin Duchemin requested to merge poweruser into master

This PR tries to give the user more control and address edge cases.

  • Added a CLI to control most of parameters (e.g. log level, acceptable difference, interaction etc)
  • Now search by artist instead of global search
  • Add an "update" mode which can update and refresh a whole playlist
  • Support for cases like "same artist in theory but split in multiple artists on the federation with different albums each time"
  • "Try-hard" mode can be enabled and makes artists/tracks searched word by word through Funkwhale to build initial candidates, and then computing differences with original. It permits to bypass the "strict" Funkwhale search, for example when there is a typo in one word it will still work
  • Ability to pass the file through stdin (pipe or tty)

Also from a code viewpoint there is a direct wrapper FunwkaleAPI for the subset of the API the script uses. By subclassing requests.Session, we can add a base URL for requests, hide get, post calls etc, and directly throwing exceptions on "bad" HTTP status code, which are well documented and consistent for Funkwhale. For example we get an exception for rate limiting, even if we don't manage the rate limit logic for now (lol we never will).

More details in code/docstring.

Drawbacks:

  • Honestly this PR makes the code a bit more complicated while maybe slightly more readable/reusable for some parts.
  • More API calls. Could find a compromise by first doing a global search limited to one result (which will be the one we are looking for in most cases, as in most cases the playlist file has been generated with export-to-txt), and only if the result does not match "well", switch to the artist-centric search logic.
Edited by Quentin Duchemin

Merge request reports