An open API service indexing awesome lists of open source software.

https://github.com/dxnter/lastfm-readme

đŸŽļ Dynamically update your GitHub README with Last.fm metrics
https://github.com/dxnter/lastfm-readme

actions github lastfm profile-readme readme

Last synced: 6 months ago
JSON representation

đŸŽļ Dynamically update your GitHub README with Last.fm metrics

Awesome Lists containing this project

README

          


lastfm-readme branding hero

# đŸŽĩ Last.fm README GitHub Action

**Dynamically update your GitHub `README.md` with [Last.fm](https://www.last.fm) metrics.**

[![MIT License][license.badge]][license]
[![GitHub Release][github.release.badge]][github.release]


lastfm-readme preview output

## 🚀 Quick Start

> [!TIP]
> **New to GitHub Actions?** Check out the [GitHub Actions documentation](https://docs.github.com/en/actions) to get started.

### 🔧 Setup

#### đŸŽĩ Last.fm API Key

1. **Create a Last.fm API account**: Visit [Last.fm API](https://www.last.fm/api/account/create)
2. **Get your API key**: You'll receive an API key immediately after account creation
3. **Save your API key**: You'll need this for the next step

> [!WARNING]
> Keep your API key secure and never commit it directly to your repository.

#### 🔒 Configure Repository Secrets

**Step 1**: Navigate to your repository's secrets:

```
Your Repository → Settings → Secrets and variables → Actions → New repository secret
```

**Step 2**: Add the required secrets:

Secret NameDescriptionRequired

LASTFM_API_KEY
Your Last.fm API key from the previous step
✅ Yes

GH_TOKEN
GitHub Personal Access Token with repo scope
Only needed for cross-repository updates
âš ī¸ Conditional

#### âš™ī¸ Configure Workflow Permissions

> [!IMPORTANT]
> This step is crucial for the action to update your README file.

**Path**: `Settings → Actions → General → Workflow permissions`

**Setting**: Select **"Read and write permissions"**


Workflow permissions configuration

#### 📝 Add Section Markers to Your README

Add HTML comments to your `README.md` where you want your Last.fm data to appear:

```html

```

### đŸ’ŧ Create Your Workflow

Create `.github/workflows/lastfm.yml` in your repository:

```yaml
name: đŸŽĩ Update Last.fm Stats

on:
# Run automatically every 6 hours
schedule:
- cron: '0 */6 * * *'
# Allow manual runs
workflow_dispatch:

jobs:
update-lastfm:
name: 🎤 Update Music Stats
runs-on: ubuntu-latest

steps:
- name: đŸŽĩ Update Last.fm README
uses: dxnter/lastfm-readme@v1
with:
LASTFM_API_KEY: ${{ secrets.LASTFM_API_KEY }}
LASTFM_USER: your-lastfm-username

# Optional: Customize the commit message
COMMIT_MESSAGE: 'đŸŽĩ Update music stats'

# Optional: For cross-repository updates
# GH_TOKEN: ${{ secrets.GH_TOKEN }}
# REPOSITORY: username/repository

# Optional: Target a different file
# TARGET_FILE: profile/README.md
```

⏰ Scheduling Examples

| Frequency | Cron Expression |
| ----------------- | --------------- |
| Every hour | `0 * * * *` |
| Every 6 hours | `0 */6 * * *` |
| Daily at midnight | `0 0 * * *` |
| Weekly | `0 0 * * 0` |

For different scheduling needs, refer to the [crontab.guru](https://crontab.guru/) website.

## âš™ī¸ Configuration

### đŸ“Ĩ Input Parameters

Parameter
Required
Default
Description

LASTFM_API_KEY
✅ Yes
—
Your Last.fm API key

LASTFM_USER
✅ Yes
—
Last.fm username to fetch data for

GH_TOKEN
đŸ”ļ Optional
${{ github.token }}
GitHub token for cross-repo updates

REPOSITORY
đŸ”ļ Optional
Current repository
Target repository (owner/repo)

TARGET_FILE
đŸ”ļ Optional
README.md
Path to the file to update

COMMIT_MESSAGE
đŸ”ļ Optional
chore: update Last.fm sections
Custom commit message

SHOW_TITLE
đŸ”ļ Optional
true
Show section titles with Last.fm logo

LOCALE
đŸ”ļ Optional
en-US
BCP 47 locale for number formatting

DATE_FORMAT
đŸ”ļ Optional
MM/dd/yyyy
date-fns format for dates

## 📊 Available Sections

> [!NOTE]
> Each section is defined by HTML comment markers with optional JSON configuration for customization.

### đŸŽ¯ Basic Usage

```html

```

### đŸ› ī¸ Advanced Configuration

```html

```

💡 Configuration Tips

- **JSON must be valid**: Use double quotes for keys and string values
- **No spaces**: Keep the configuration compact
- **Multiple sections**: You can use the same section type multiple times with different configs

**Example of multiple artist sections:**

```html

```

---

### 🎤 Top Artists

Display the top listened to albums over a given period of time.

#### đŸ–ŧī¸ Preview

![top-artists.png](./static/images/top-artists.png)

#### đŸ’ģ Usage Examples

```html

```

#### âš™ī¸ Configuration Options

OptionTypeDefaultOptionsDescription

period
string
7day
7day, 1month, 3month, 6month, 12month, overall
Time period for data aggregation

rows
number
8
1-50
Number of artists to display

### đŸ’ŋ Top Albums

Display the top listened to albums over a given period of time.

#### đŸ–ŧī¸ Preview

![top-albums.png](./static/images/top-albums.png)

#### đŸ’ģ Usage Examples

```html

```

#### âš™ī¸ Configuration Options

OptionTypeDefaultOptionsDescription

period
string
7day
7day, 1month, 3month, 6month, 12month, overall
Time period for data aggregation

rows
number
8
1-50
Number of albums to display

### đŸŽĩ Top Tracks

Display the top listened to tracks over a given period of time.

#### đŸ–ŧī¸ Preview

![top-tracks.png](./static/images/top-tracks.png)

#### đŸ’ģ Usage Examples

```html

```

#### âš™ī¸ Configuration Options

OptionTypeDefaultOptionsDescription

period
string
7day
7day, 1month, 3month, 6month, 12month, overall
Time period for data aggregation

rows
number
8
1-50
Number of tracks to display

### 🔊 Recent Tracks

Display most recently played music with real-time "now playing" status.

#### đŸ–ŧī¸ Preview

**Default**

![recent-tracks.png](./static/images/recent-tracks.png)

**Track currently playing**

![recent-tracks-now-playing.png](./static/images/recent-tracks-now-playing.png)

#### đŸ’ģ Usage Examples

```html

```

#### âš™ī¸ Configuration Options

OptionTypeDefaultOptionsDescription

rows
number
8
1-50
Number of recent tracks to display

### â„šī¸ User Statistics

Showcase your Last.fm profile statistics and listening milestones.

#### đŸ–ŧī¸ Preview

**Default**

![recent-tracks.png](./static/images/user-info-default.png)

**Custom Configuration**

![user-info-custom.png](./static/images/user-info-custom.png)

#### đŸ’ģ Usage Examples

```html

```

#### âš™ī¸ Configuration Options

OptionTypeDefaultAvailable OptionsDescription

display
array
All fields
registered, playcount, artistCount, albumCount, trackCount
List of statistics to display

📊 Available Statistics Fields

| Field | Description | Example Output |
| ------------- | -------------------------- | -------------------------- |
| `registered` | Account registration date | **Registered**: 12/25/2015 |
| `playcount` | Total scrobbled tracks | **Playcount**: 50,247 |
| `artistCount` | Unique artists listened to | **Artists**: 2,847 |
| `albumCount` | Unique albums in library | **Albums**: 8,429 |
| `trackCount` | Unique tracks in library | **Tracks**: 45,821 |

## 🌟 Acknowledgements

This project was inspired by and builds upon the excellent work of:

- [JasonEtco/rss-to-readme](https://github.com/JasonEtco/rss-to-readme)
- [vnphanquang/monkeytype-readme](https://github.com/vnphanquang/monkeytype-readme)
- [athul/waka-readme](https://github.com/athul/waka-readme)
- [actions-js/profile-readme](https://github.com/actions-js/profile-readme)

[license.badge]: https://img.shields.io/badge/license-MIT-red.svg
[license]: ./LICENSE
[github.release.badge]: https://img.shields.io/github/v/release/dxnter/lastfm-readme
[github.release]: https://github.com/dxnter/lastfm-readme/releases