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
Metadata
Release files for offline-listens 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| offline_listens-0.1.0.tar.gz | 6.1 kB | Without provenance | Details for offline_listens-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| offline_listens-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for offline_listens-0.1.0-py3-none-any.whl |
Total release size: 13.2 kB
Release files / offline_listens-0.1.0.tar.gz
| Download URL | offline_listens-0.1.0.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad0c0f58b9172f8582a8f4eb960c8d25355f3282336c5f662e6e6cf1c1b46c42
|
|
BLAKE2b-256 checksum How to use checksums |
8f9b1b8cba45d4908aeb52db0f3ebcc4a0fb6c58716fb187fd3481e302cb79cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / offline_listens-0.1.0-py3-none-any.whl
| Download URL | offline_listens-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
33af7e592fc2a5618682031c4b2518b77a10fd477d8cf035df6345d017add97b
|
|
BLAKE2b-256 checksum How to use checksums |
9ab4de2fa4541edb7a4d9ccf855bf16fb793560373b36bdb90a052224a4670e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for offline-listens 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.