about summary refs log tree commit diff
path: root/tools/mpd-stats (follow)
Commit message (Collapse)AuthorAgeFilesLines
* mpd: we only want events from the player subsystemFranck Cuny2022-06-112-2/+8
| | | | | Store the name of the subsystem in a constant, add some comments on where to find the list.
* doc: update README with instruction for installingFranck Cuny2022-06-111-0/+8
|
* build: install the binary and systemd unitFranck Cuny2022-06-111-0/+12
| | | | | | Add a Makefile to install the binary in GOPATH and the unit file for the service. When the binary is installed, systemd is reloaded and the service is also started.
* scrobbler: add a systemd unit fileFranck Cuny2022-06-111-0/+43
| | | | | | | | | | | | As I want the scrobbler to be started automatically when I log into my session, the easiest way to do this is by having a systemd unit file that I run for my own user. The unit expects that the binary for the scrobbler is under my $GOPATH, which is hard coded for now. We also ensure that the binary exists before starting the unit. We harness the service with a number of directives.
* scrobbler: read mpd status before processing songFranck Cuny2022-06-111-4/+21
| | | | | | | | If the status of the player is "stop", we don't have a new song to handle. In this case, if there's a current song, let's update the status and clear our state. Closes #1.
* scrobbler: record how long a song was playedFranck Cuny2022-06-112-1/+16
| | | | | | | | Add a column `playtime` to the records table to keep track of how long a song was played. With this information, in the future, we will be able to sum up how long we listen to music, but also which songs were skipped.
* mpd-scrobbler: proper default argumentsFranck Cuny2022-06-111-2/+31
| | | | | | | | The program needs two arguments: the mpd host and port, which can be passed as flags (default is to use the local instance of mpd). We store the database in `XDG_CONFIG_HOME/mpd-scrobbler`, and we create the path if needed.
* scrobbler: use helper function EqualAttrsFranck Cuny2022-06-111-3/+1
| | | | | | To compare the current attributes with the current record, we can use the helper `EqualAttrs` which will tell us if we need to create a new record or not.
* record: add some basic testingFranck Cuny2022-06-112-0/+59
|
* mpd-stats: pass database path to the scrobblerFranck Cuny2022-06-112-5/+31
| | | | | | | | When creating a scrobbler, we provide the path to the database. The scrobbler then get a handler to the database. When a new record is created, we persist it to the database using the `save` function.
* scrobbler: add timestamp to the recordFranck Cuny2022-06-111-9/+11
| | | | When we create a new record, let's capture when this was created.
* scrobbler: add interface to the sqlite3 databaseFranck Cuny2022-06-113-0/+57
| | | | | | | | | We want to persist the records in a database, so we can extract statistics and an history. The module for the database is straightforward: it opens the database if it exists and return an handler to it. If the database does not exists, we create it and we create the only table we need (records).
* mpd-stats: create and run the scrobblerFranck Cuny2022-06-111-39/+4
|
* scrobbler: add functions to create and run itFranck Cuny2022-06-111-0/+66
| | | | | | | | | | | | Add a new function to create a scrobbler. The function takes care of creating the mpd client. Add a function to run the scrobbler, which takes care of creating a new record when needed. This will simplify the interface for the caller, as all they really care about is: create the scrobbler, close it when we're done, and collect songs information while we listen to our music.
* mpd: export the type PlayerFranck Cuny2022-06-111-4/+4
|
* mpd: add function `Close` to the playerFranck Cuny2022-06-112-2/+15
| | | | | Let's close both the watcher and the client, instead of leaking this interface to the user.
* mpd: rename function to create the playerFranck Cuny2022-06-112-2/+2
|
* scrobbler: create a record on new songFranck Cuny2022-06-111-5/+27
| | | | | | When we receive an event from the player, we look if the song is different from the previous one, and we create a new record if that's the case. If the song is similar, there's nothing to do.
* scrobbler: initial log record typeFranck Cuny2022-06-113-1/+40
| | | | | Define the type for a log record and add an helper function to create a new record.
* scrobbler: watch for events and print song detailsFranck Cuny2022-06-114-0/+77
| | | | | | | | | | We create a module "mpd" to interact with our MPD instance. For now we only have a single function to create a new client, which creates an actual client for mpd (and we ping the instance every 30 seconds), and a watcher to receive new events. The tool "scrobbler" then wait for new events and display songs information.
* README: add some information about loggingFranck Cuny2022-06-111-1/+14
| | | | Describe what is being collected.
* add initial go.modFranck Cuny2022-06-111-0/+3
|
* Add README.org, LICENSE.txtFranck Cuny2022-06-112-0/+21