Skip to content

TweeZee/lastfm-broker

Repository files navigation

lastfm-broker

Small tool to continuously fetch current track information and pass it to simple, customizable hooks e.g. dumping into a text file for a now-playing-bar in livestreams or publishing it to your home assistant via MQTT. Bare-bones, with support for configuration via command line arguments, .env files and a typescript config file.

Available Hooks

  • MQTT - publish the current track info to a MQTT broker
  • File Dump - write the current track info to a text file
  • HTTP Server - expose the current track info via a simple HTTP endpoint
  • GeekMagic - send the current track's album cover to a GeekMagic device

Configuration and Development

  1. Install bun and (optionally) go-task

  2. Get yourself a last.fm API-Key here (you do not need to enter a callback URL for this tool).

  3. go into packages/core, copy the .env.example-file and rename the copy to .env. enter your last.fm API-Key and your last.fm username.

  4. Install dependencies:

bun install
  1. copy the config.example.ts file in packages/core/src to config.ts and adjust the configuration to your needs. Every hook-package should expose a builder function that can be used to create a hook. The hook will be called with the current track info every time it changes.

  2. run the tool:

bun run --bun index.ts

from the packages/core directory or (if you installed go-task) simply run

task dev

anywhere in the repository.

the following parameter are available

  • --interval <number> - the interval (in milliseconds) in which the current track info should be requested and updated (don't set this too low or you might run into API limits)
  • --allow-inactive-tracks - whether the broker should pass inactive tracks to the hooks; if not set, the broker will only pass actively playing tracks to the hooks
  • --help - show a help message

Deployment and Usage

there are multiple ways to deploy and use this tool:

  • simply run it on your local machine using bun run
  • run it in a docker container using the provided Dockerfile (you can build and run the image using task container:up)
  • compile it to a binary using task build and run it on your server

If you have written a cool hook, feel free to open a PR and I might add it to the repository!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors