1.4.2 • Published 1 year ago

lastfm-readme v1.4.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

GitHub README Last.fm Metrics

Dynamically update your GitHub README.md with Last.fm metrics.

MIT github.release.badge actions.codeql.badge

⚡ Usage

Preparation

Last.fm API Key

Create a Last.fm API account if you don't have one to receive an API Key.

Save GitHub Action Secrets

Navigate to your repositories Settings → Secrets and variables → Actions → New repository secret to add the following secrets:

NameValue
LASTFM_API_KEYA valid Last.fm API Key
GH_TOKEN*A GitHub Access Token with the repo scope granted

* GH_TOKEN is only required when the intention is to modify a README.md file in a repository outside where the workflow is running.

Update the workflow permissions on your repository

Navigate to your repositories Settings → Actions → General → Workflow permissions and select the Read and write permissions option.

workflow-permissions.png

Add chart HTML comments to your README

The README.md file must contain HTML comments that identify where the charts should be inserted. Commonly, a profile repository is used to host the README.md file.

Note See the Charts section for configuration details.

Example Workflow

name: Last.fm Charts

on:
  workflow_dispatch: # Allow manual triggering of workflow
  schedule:
    # Run every 6 hours
    - cron: '0 */6 * * *'

jobs:
  lastfm-metrics:
    name: Update Last.fm Charts
    runs-on: ubuntu-latest
    steps:
      - uses: dxnter/lastfm-readme@v1
        with:
          LASTFM_API_KEY: ${{ secrets.LASTFM_API_KEY }}
          LASTFM_USER: dxnter
          # The following inputs below are only required when the intention is to modify a README.md file in a repository outside where the workflow is running
          #GH_TOKEN: ${{ secrets.GH_TOKEN }}
          #REPOSITORY: <gh_username/gh_username>

Inputs

SettingDefaultAccepted ValuesDescription
LASTFM_API_KEYN/ALast.fm API KeyA valid Last.fm API Key
LASTFM_USERN/ALast.fm usernameThe Last.fm user to fetch metrics from
GH_TOKEN${{ github.token }}GitHub access tokenAn access token with the repo scope granted.
REPOSITORY<gh_username>/<gh_username><gh_username>/<repo_name>Repository that should have the README.md file updated.
COMMIT_MESSAGEchore: update Last.fm sectionsAny stringCommit message used when sections are updated
SHOW_TITLEtruetrue / falseToggle the title shown above sections
LOCALEen-USBCP 47 tagLocale used for formatting numbers
DATE_FORMATMM/dd/yyyydate-fns date formatDate format used in the User Info section

📊 Charts

All charts are identified by HTML comments that contain a valid chart name and an optional JSON configuration object followed by a closing HTML comment.

Chart with the default configuration (period: "7day", rows: 8)
<!--START_LASTFM_...-->
<!--END_LASTFM_...-->

Chart with a custom configuration
<!--START_LASTFM_...:{"period": "overall", "rows": 3}-->
<!--END_LASTFM_...-->

🎤️ Top Artists

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

Example

<!--START_LASTFM_ARTISTS:{"period": "6month", "rows": 3}-->
<!--END_LASTFM_ARTISTS-->

Output

top-artists.png

Configuration

OptionDefaultOptionsDescription
period7day7day, 1month, 3month, 6month, 12month, overallThe period of time to display data from
rows81 ≤ integer ≤ 50The number of artists to display

💿 Top Albums

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

Example

<!--START_LASTFM_ALBUMS:{"period": "1month", "rows": 3}-->
<!--END_LASTFM_ALBUMS-->

Output

top-albums.png

Configuration

OptionDefaultOptionsDescription
period7day7day, 1month, 3month, 6month, 12month, overallThe period of time to display data from
rows81 ≤ integer ≤ 50The number of albums to display

🎵 Top Tracks

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

Example

<!--START_LASTFM_TRACKS:{"period": "1month", "rows": 3}-->
<!--END_LASTFM_TRACKS-->

Output

top-tracks.png

Configuration

OptionDefaultOptionsDescription
period7day7day, 1month, 3month, 6month, 12month, overallThe period of time to display data from
rows81 ≤ integer ≤ 50The number of tracks to display

🔊 Recent Tracks

Display recently listened to tracks.

Example

<!--START_LASTFM_RECENT:{"rows": 3}-->
<!--END_LASTFM_RECENT-->

Output

Default

recent-tracks.png

Track currently playing

recent-tracks-now-playing.png

Configuration

OptionDefaultOptionsDescription
rows81 ≤ integer ≤ 50The number of recent tracks to display

ℹ️ User Info

Display information about a Last.fm user. An optional configuration object can be passed to specify which properties to display.

Example (Default)

<!--START_LASTFM_USER_INFO-->
<!--END_LASTFM_USER_INFO-->

Output

recent-tracks.png

Example (Custom Configuration)

<!--START_LASTFM_USER_INFO:{"display": ["playcount", "artistCount"]}-->
<!--END_LASTFM_USER_INFO-->

Output

user-info-custom.png

Configuration

OptionDefaultOptionsDescription
display["registered", "playcount", "artistCount", "albumCount", "trackCount"]registered, playcount, artistCount, albumCount, trackCountA list of properties to be included in the section

🌟 Acknowledgements

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.1.1

1 year ago