1 stable release
Uses old Rust 2015
1.0.0 | Mar 30, 2018 |
---|
#11 in #fm
25KB
697 lines
NowPlaying bot
A "nowplaying" bot that can draw from multiple sources and send to multiple destinations
Sources
Currently, the implemented sources are:
- Bose SoundTouch speakers
- Last.fm
Sinks
Currently, the implemented sinks are:
- Mastodon
Running
To run, you will need to supply a few things. You'll need a YouTube Data API key, so go to the google developer
console and get one of those. It can be provided to the program through the YOUTUBE_KEY
environment variable.
In order to use one of the sources, you'll also need to supply some information about it. For the last.fm
source, get a last.fm API key and assign it to the LASTFM_API_KEY
environment variable, along with your
last.fm username in the LASTFM_USERNAME
environment variable. The SoundTouch source only needs the
hostname of your SoundTouch speaker, in the SOUNDTOUCH_HOST
environment variable.
Environment variables can be set on the command line, or in a .env
file.
When the program starts, it will attempt to find a mastodon access token in the creds.json
file. If the
file doesn't exist, the program will prompt you on what to do to give it access to post to your mastodon
account.
Adding a new source
Adding a new source is not too hard, this commit shows a good example:
https://gitlab.com/pwoolcoc/npbot/commit/4eddf89266c71677511e2cba86a69c8fe60db3ec
Basically the steps are:
- add a submodule to the
src/source
module - in your new submodule, add a data structure that implements the
Source
trait. - (optional) add a
.from_env(cli_args: Opt) -> Self
static method to your data structure if you want to use thedetect_and_register!
macro insrc/main.rs
. - in
src/main.rs
, add any necessary cli arguments, and under the// Sources
line inmain
, add the necessary code to detect and register the new source
TODO
- tests & ci
- use mdns to find soundtouch host, fallback to env var/cli arg
- better story around using multiple sources?
- moar sources
- moar sinks
Dependencies
~25–35MB
~623K SLoC