@freeyourmusic/cli
v11.3.0
Published
Command-line interface for FreeYourMusic. Uses your FreeYourMusic account on freeyourmusic.com: transfers, library, playlist tools, insights and stats. Needs FreeYourMusic Pro.
Readme
@freeyourmusic/cli
The FreeYourMusic command-line interface. It uses your FreeYourMusic account, the same account as the web app at freeyourmusic.com/app: connected services, library, transfers, sync, playlist tools, insights, stats and exports. The CLI needs FreeYourMusic Pro.
Quickstart
npm i -g @freeyourmusic/cli
fym login # opens freeyourmusic.com/app/cli; sign in and tap Allow
fym status
fym services connect spotify
fym library playlists --account-id <uuid>fym login works with every sign-in method of your account (email, Apple, Google). On a machine
without a browser, open the printed URL on another device (--no-browser). For CI, set
FYM_TOKEN to an owner token instead.
Commands
Run fym help, fym <group> --help and fym <command> --help. Every command takes --json.
The commands come from the FreeYourMusic web API: one command for each operation of musicapi
/v1/fym (musicapi/openapi-fym.json) and of server /fym-account. Flags are the input names in
kebab case (--transfer-uuid); required inputs can also be given in order as arguments. A complex
input takes JSON or @file.json, and --input @file.json takes the whole input.
| Group | What |
|---|---|
| login, logout, status | Sign-in and the account state |
| services, accounts | Music services: services connect <service>, services reconnect <accountUuid>, accounts list, accounts refresh, accounts remove |
| library | Collections, playlists, songs, refresh |
| playlists, covers | Playlist details, create, edits (add, remove, move, rename, describe), tools (sort, shuffle, dedupe, split), copy, merge, delete, versions, covers |
| queue | The queue of the account: queue get, queue enqueue, queue cancel, queue dismiss |
| search | The catalogue search of a service |
| transfers | Create, list, progress, items, pause, resume, delete, sync, retry, recreate, export |
| matches | Songs that were not found: search, pick, reject |
| insights | Playlist insights and share cards |
| stats | Listening stats, sections, shares |
| exports | Library exports |
| notifications, account, premium | Preferences, email, Pro plans, checkout, licence keys |
| watch | Live events of the account |
Commands that delete or replace data need --yes. There is no transfer cancel: pause or delete a
transfer.
Every write to a playlist joins the queue of the account, as in the app: playlists delete,
playlists merge, covers upload and the others answer at once with the queue action, and
FreeYourMusic runs it on the server. Run fym queue get to see how it ended. fym queue enqueue
takes any action as JSON, for example a delete of up to 200 playlists in one action. It asks for
--yes for a delete, and for a merge with keepOriginals false.
Free and Pro
The CLI is a Pro feature. The sign-in (fym login) asks for an account with Pro; the
browser page offers Pro to a free account. When Pro ends, only the account commands work
(fym account, fym premium plans, fym premium buy <plan>); every other command exits with
code 4.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Wrong input, or the API refused the input |
| 2 | Not signed in, or the session ended (fym login) |
| 3 | FreeYourMusic could not be reached, or an unexpected error |
| 4 | Pro needed |
| 5 | Too many requests |
Environments and files
--env production|rc|local(orFYM_ENV).rc(=staging) uses the RC servers (api.stampapp.io,api.musicmigrator.com,site.stampapp.io/app) to test an RC release:fym login --env rc, thenfym status --env rc. Each environment keeps its own session.FYM_MUSICAPI_URL,FYM_SERVER_URL,FYM_MUSIC_APP_URLandFYM_WEB_URLoverride the hosts (localneeds all four).~/.fym/credentials.json(mode 0600) keeps one owner token per environment. The CLI refreshes it before its last 7 days.fym logoutdeletes it on this computer;fym account sign-out-everywhereends the other sessions too.FYM_NO_BROWSER=1never opens a browser.
Error reporting
Published builds report unexpected failures to FreeYourMusic's Sentry project. Tokens, request
payloads and arguments are not attached. Development and test builds do not report. Set
FYM_DISABLE_TELEMETRY=1 to turn reporting off, or SENTRY_DSN to use your own destination.
Maintainers
- The version is in
packages/fym-cli/package.json(the MCP package uses the same version).rc-fym-clipublishes<version>-rc.<iid>with the npm tagnext,master-fym-clipublishes<version>withlatest(gitlab-ci/.publish.yml,ci/fym-cli/stage-npm-packages.sh; the publish runs in gitlab.com/freeyourmusic/npm-packages). - Bump the version in
packages/fym-cli/package.jsonon develop right after eachmaster-fym-clirelease. Else the nextrc-fym-clipublishes<old>-rc.<iid>, which npm sorts below the released<old>, and the tagnextpoints at an older version thanlatest. - After a change of
musicapi/openapi-fym.json, runpnpm --filter @freeyourmusic/cli-client gen:operations. - Checks:
pnpm tsc-lint:fym-cli,pnpm lint:fym-cli,pnpm test:fym-cli(CI jobtest-fym-cli).
