An unofficial set of tools for Cool Cats™.
Project description
GRRIF Tools
A set of tools for Cool Cats™.
GRRIF Tools allows you to archive GRRIF radio's play history to a SQLite database or text files, compute statistics (top artists and tracks), stream the radio live in your console, and scrobble tracks to Last.fm.
Features
- Archive play history: Save GRRIF's played tracks to a SQLite database or text files.
- Statistics: View top artists and tracks over custom date ranges.
- Live streaming: Listen to GRRIF radio directly in your terminal.
- Last.fm scrobbling: Automatically scrobble tracks while streaming or in standalone mode.
- TUI interface: User-friendly terminal interface for all features.
Installation
pip install grrif-tools
Usage
GRRIF Tools can be used in two ways:
1. Terminal User Interface (TUI)
For a user-friendly interface, simply run:
grrif_tools --tui
Navigate through the menu with arrow keys and select options with Enter. The TUI provides access to all features with an intuitive interface.
2. Command Line Interface (CLI)
usage: grrif_tools [-h] [--tui] {archive,stats,play,scrobble} ...
GRRIF Tools v0.9.1: A set of tools for Cool Cats™. Allows you to archive GRRIF's play history, view stats,
stream the radio, and scrobble to Last.fm.
positional arguments:
{archive,stats,scrobble,play}
archive Archive GRRIF's play history.
stats Get statistics from the play history.
scrobble Scrobble to Last.fm.
play Stream GRRIF radio in the console.
options:
-h, --help show this help message and exit
--tui Launch the terminal user interface
Archive
Archive GRRIF's play history to a database, text files, or print to stdout:
# Archive to SQLite database
grrif_tools archive db [from_date] [to_date]
# Archive to text files
grrif_tools archive txt [from_date] [to_date]
# Print to stdout
grrif_tools archive print [from_date] [to_date]
Dates should be in YYYY-MM-DD format. If omitted, defaults to 2021-01-01 and today.
Statistics
View statistics about most played artists or tracks:
# View top 10 artists
grrif_tools stats artists top10 [from_date] [to_date]
# View top 25 tracks
grrif_tools stats tracks top25 [from_date] [to_date]
# View top 100 artists
grrif_tools stats artists top100 [from_date] [to_date]
Streaming
Listen to GRRIF radio in your terminal:
# Stream with high quality MP3
grrif_tools play mp3_high
# Stream with low quality MP3
grrif_tools play mp3_low
# Stream with high quality AAC
grrif_tools play aac_high
The console will display the currently playing track and scrobble it to Last.fm if credentials are configured.
Last.fm Scrobbling
GRRIF Tools provides a simple way to set up Last.fm scrobbling:
# Authenticate with Last.fm (interactive)
grrif_tools scrobble authenticate API_KEY API_SECRET
# Manually set Last.fm credentials (if you already have a session key)
grrif_tools scrobble settings API_KEY API_SECRET SESSION_KEY
# Start scrobbling
grrif_tools scrobble start
The authenticate command handles the full Last.fm authentication flow:
- Requests a token from Last.fm
- Opens your browser to authorize the application
- Waits for your confirmation
- Retrieves and saves your session key automatically
Scrobbling will automatically track what's playing on GRRIF and send it to your Last.fm account.
Last.fm Authentication
To use the scrobbling feature, you'll need a Last.fm API account:
- Create an API account at https://www.last.fm/api/account/create
- Get your API key and secret
- Run the authentication command:
grrif_tools scrobble authenticate YOUR_API_KEY YOUR_API_SECRET
- Follow the prompts to authorize the application in your browser
- Once authorized, your session key will be saved automatically
If you prefer to handle the authentication process manually, you can still use the traditional method:
- Get a token from https://www.last.fm/api/auth with your API key
- Authorize the token by visiting https://www.last.fm/api/auth?api_key=YOUR_API_KEY&token=YOUR_TOKEN
- Create an MD5 hash of "api_key[your api key]methodauth.getSessiontoken[your token][your api secret]"
- Send a request to https://ws.audioscrobbler.com/2.0/?method=auth.getSession&api_key=YOUR_API_KEY&token=YOUR_TOKEN&api_sig=YOUR_MD5_HASH
- Set the obtained session key with
grrif_tools scrobble settings API_KEY API_SECRET SESSION_KEY
Data Storage
All data is stored in your home directory under ~/grrif_data/:
- SQLite database:
~/grrif_data/grrif_data.db - Text files:
~/grrif_data/plays/YYYY/MM/DD.txt - Configuration:
~/grrif_data/config.json - Temporary buffer file:
~/grrif_data/buferr.mp3
Examples
Archiving the last week of plays
# Get today's date
today=$(date +%Y-%m-%d)
# Get date from a week ago
last_week=$(date -d "7 days ago" +%Y-%m-%d)
# Archive to database
grrif_tools archive db $last_week $today
Finding your favorite artists from the last month
# Get today's date
today=$(date +%Y-%m-%d)
# Get date from a month ago
last_month=$(date -d "30 days ago" +%Y-%m-%d)
# Show top 25 artists
grrif_tools stats artists top25 $last_month $today
Setting up scrobbling and leaving it running
# Start in a screen session
screen -S grrif-scrobble
# Start scrobbling (after authentication)
grrif_tools scrobble start
# Detach with Ctrl+A then D
Notes
This package is unofficial and meant as a fun tool for GRRIF radio fans. Please be considerate and don't overload GRRIF's website with requests.
Development
If you want to contribute to the development:
- Clone the repository:
git clone https://github.com/fetzu/grrif-tools.git - Create a virtual environment:
python -m venv venv - Activate it:
source venv/bin/activate(Linux/macOS) orvenv\Scripts\activate(Windows) - Install in development mode:
pip install -e . - Run linting:
pylint grrif_tools - Submit a PR with your changes
License
MIT License
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 grrif_tools-0.9.1.tar.gz.
File metadata
- Download URL: grrif_tools-0.9.1.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57f3ec80c5e1e002f03f11610bf2580794c8ef5ff5cb13c75006e1fffc048e49
|
|
| MD5 |
5ad523fc60c3d248edf0558b8031684a
|
|
| BLAKE2b-256 |
b506e9f1d23aef9850f23269ca7c3931a8d5cc8db54453ed73a684aeaa82638b
|
File details
Details for the file grrif_tools-0.9.1-py3-none-any.whl.
File metadata
- Download URL: grrif_tools-0.9.1-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78c45d0fc3980200bd2b4d8d180181183098b6df4820a79d3fe8a4f960d5662c
|
|
| MD5 |
da8acecd30054b50abf9cf38bbb42eed
|
|
| BLAKE2b-256 |
12c641f25a75fbbed37f69a3e7283f5a86e54b456e86e34afe9a46c8f8fac7bf
|