an offline listening history
Project description
offline_listens
An offline listening history.
This lets me keep track of music I listen to when offline, or when its not possible to sync with my scrobbler to listenbrainz/last.fm or on my computer with mpv
This is very generic -- it accepts one or more commands that generate JSON data in the format:
{
"artist": "Artist Name",
"album": "Album Name",
"track": "Track Name",
}
as a list of JSON objects, one per line like (without the surrounding []):
{"artist": "Artist Name", "album": "Album Name", "track": "Track Name"}
{"artist": "Artist Name", "album": "Album Name", "track": "Track Name"}
{"artist": "Artist Name", "album": "Album Name", "track": "Track Name"}
...and then lets you pick one of those, and then saves it to a file.
If you don't select one of those, it'll just prompt you to manually enter each field
This is then combined into HPI listens in the my.offline.listens module
Installation
Requires python3.9+
To install with pip, run:
pip install git+https://github.com/purarue/offline_listens
Usage
Usage: offline_listens [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
dump dump listens
listen add a listen
parse parse an offline listens file
update-cache update cache file
By default this saves to ~/.local/share/offline_listens/listens.json. You can override that by passing the filename to listen, or by setting the OFFLINE_LISTENS_FILE environment variable. That can be a .json or .yaml file, like:
export OFFLINE_LISTENS_FILE="${HOME}/Documents/listens.yaml"
To use this, you need to set the OFFLINE_LISTENS_COMMANDS environment variable to a list of commands (separated with :, like a $PATH) that generate JSON data in the format above.
When you run this for the first time, it runs that command and generates a cache at ~/.cache/offline-listens.json, which is then used when you are asked to pick a song you just listened to. To update that cache, you can run offline_listens update-cache.
For my OFFLINE_LISTENS_COMMANDS, I use a single command, using my listens script, with a small wrapper which removes the date/only returns unique songs
So my config just looks like:
export OFFLINE_LISTENS_COMMANDS='offline-listens-source'
If you don't have any sources, you could just create a script like this, which parses the offline listens file itself:
#!/usr/bin/env bash
python3 -m offline_listens parse | jq '.[] | del(.when)' -c | sort | uniq
To generate the correct JSON, I would recommend jq
- To convert a list into a list of JSON objects, you can use
some-command-which-makes-json | jq '.[]' - To compress the JSON, you can use
some-command-which-makes-json | jq -c
Tests
git clone 'https://github.com/purarue/offline_listens'
cd ./offline_listens
pip install '.[testing]'
flake8 ./offline_listens
mypy ./offline_listens
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file offline_listens-0.1.0.tar.gz.
File metadata
- Download URL: offline_listens-0.1.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad0c0f58b9172f8582a8f4eb960c8d25355f3282336c5f662e6e6cf1c1b46c42
|
|
| MD5 |
9afbc4f8578fb2f55099cf0fe1d004c1
|
|
| BLAKE2b-256 |
8f9b1b8cba45d4908aeb52db0f3ebcc4a0fb6c58716fb187fd3481e302cb79cb
|
File details
Details for the file offline_listens-0.1.0-py3-none-any.whl.
File metadata
- Download URL: offline_listens-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33af7e592fc2a5618682031c4b2518b77a10fd477d8cf035df6345d017add97b
|
|
| MD5 |
700bf4c9400eedf4c55449734fd88be7
|
|
| BLAKE2b-256 |
9ab4de2fa4541edb7a4d9ccf855bf16fb793560373b36bdb90a052224a4670e2
|