A command-line application to view your latest artists from Last.fm, written in Rust.
- 🎵 Fetch your top artists from Last.fm
- 📊 Multiple output formats: Social media text (default), JSON, and CSV
- ⚡ Async HTTP with automatic retry logic
- 🔒 Secure HTTPS API calls
- 📝 Structured logging with adjustable verbosity
- ⚙️ Configuration via environment file or CLI arguments
- ✅ Comprehensive test coverage
cargo build --releaseThe executable will be located at target/release/lfmc.
- Rust 1.66.1 or later
- A Last.fm API key (get one at https://www.last.fm/api)
lfmc --api-key <YOUR_API_KEY> --username <YOUR_USERNAME>lfmc \
--api-key <API_KEY> \
--username <USERNAME> \
--period 7day \
--limit 5 \
--format socialPerfect for sharing on social media:
lfmc -k <API_KEY> -u <USERNAME> --format socialOutput:
♫ My Top 5 played artists in the past week: Artist 1 (100), Artist 2 (90), Artist 3 (80), Artist 4 (70), & Artist 5 (60). Via #LastFM ♫
For programmatic processing:
lfmc -k <API_KEY> -u <USERNAME> --format jsonFor spreadsheet analysis:
lfmc -k <API_KEY> -u <USERNAME> --format csvCreate a .env file at $HOME/.config/lfmc/.env:
API_KEY=your_lastfm_api_key
USERNAME=your_lastfm_username
PERIOD=7day
LIMIT=5You can use the provided .env.sample as a template:
mkdir -p ~/.config/lfmc
cp .env.sample ~/.config/lfmc/.env
# Edit the file with your credentialsThen run without arguments:
lfmc| Option | Short | Environment Variable | Default | Description |
|---|---|---|---|---|
--api-key |
-k |
API_KEY |
Required | Your Last.fm API key |
--username |
-u |
USERNAME |
Required | Your Last.fm username |
--limit |
-l |
LIMIT |
5 | Number of artists to fetch (1-50) |
--period |
-p |
PERIOD |
7day | Time period (see below) |
--format |
-f |
- | social | Output format (social, json, csv) |
--verbose |
-v |
- | - | Increase logging verbosity (-v, -vv, -vvv) |
overall- All time7day- Last 7 days1month- Last month3month- Last 3 months6month- Last 6 months12month- Last 12 months
lfmc -k YOUR_KEY -u YOUR_USERNAMElfmc -k YOUR_KEY -u YOUR_USERNAME --period overall --limit 10 --format jsonlfmc -k YOUR_KEY -u YOUR_USERNAME --period 1month -vvlfmc -k YOUR_KEY -u YOUR_USERNAME --format csv > my_artists.csvcargo buildcargo testcargo clippycargo fmtLFMC follows a modular architecture:
- API Client: Async HTTP client with retry logic and exponential backoff
- Configuration: Type-safe config with validation
- Formatters: Pluggable output formatters (social, JSON, CSV)
- Error Handling: Custom error types with helpful messages
- Testing: Unit, integration, and CLI end-to-end tests
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.