← Back to plugins index

🎼 Music activity and suggestions

This plugin can display top and recently listened music tracks or titles from a random playlist.

Different music providers are supported.

⚠️ Disclaimer

This plugin is not affiliated, associated, authorized, endorsed by, or in any way officially connected with any of the supported provider. All product and company names are trademarks™ or registered® trademarks of their respective holders.

Supported features
→ Full specification
📗 Classic template
👤 Users 👥 Organizations
🗝️ plugin_music_token
Random tracks from a playlist
Recently listened
#### ➡️ Available options
OptionDescription

plugin_music

Enable music plugin

✨ On master/main
🌐 Web instances must configure settings.json:
  • metrics.run.puppeteer.scrapping
type: boolean
default: no

plugin_music_provider

Music provider

  • apple: Apple Music
  • spotify: Spotify
  • lastfm: Last.fm
  • youtube: YouTube Music

This setting is optional when using plugin_music_mode: playlist (provider will be auto-detected from plugin_music_playlist URL)

✨ On master/main
type: string
allowed values:
  • apple
  • spotify
  • lastfm
  • youtube

plugin_music_token

Music provider token

Below is the expected token format for each provider:

  • apple: (not supported)
  • spotify: "client_id, client_secret, refresh_token"
  • lastfm: "api_key"
  • youtube: "cookie"
🔐 Token
✨ On master/main
🌐 Web instances must configure settings.json:
  • metrics.api.music.any
type: token

plugin_music_user

Music provider username

⏯️ Cannot be preset
✨ On master/main
type: string
default: → User login

plugin_music_mode

Display mode

  • playlist: display random tracks from an URL playlist
  • recent: display recently listened tracks
  • top: display top listened artists/tracks

If plugin_music_playlist is specified, the default value is playlist, else it is recent

✨ On master/main
type: string
allowed values:
  • playlist
  • recent
  • top

plugin_music_playlist

Playlist URL

It must be from an "embed url" (i.e. music player iframes that can be integrated in other websites)

⏯️ Cannot be preset
✨ On master/main
type: string

plugin_music_limit

Display limit

✨ On master/main
type: number (1 ≤ 𝑥 ≤ 100)
default: 4

plugin_music_played_at

Recently played - Last played timestamp

✨ On master/main
type: boolean
default: no

plugin_music_time_range

Top tracks - Time range

  • short: 4 weeks
  • medium: 6 months
  • long: several years
✨ On master/main
type: string
default: short
allowed values:
  • short
  • medium
  • long

plugin_music_top_type

Top tracks - Display type

  • tracks: display track
  • artists: display artists
✨ On master/main
type: string
default: tracks
allowed values:
  • tracks
  • artists
## 🎺 Configuring music provider Select a music provider below for additional instructions. ## 🎙️ Spotify ### 🗝️ Obtaining a token Spotify does not have *personal tokens*, so it makes the process a bit longer because it is required to follow the [authorization workflow](https://developer.spotify.com/documentation/general/guides/authorization-guide/)... Follow the instructions below for a *TL;DR* to obtain a `refresh_token`. Sign in to the [developer dashboard](https://developer.spotify.com/dashboard/) and create a new app. Keep your `client_id` and `client_secret` and let this tab open for now. ![Add a redirect url](/.github/readme/imgs/plugin_music_recent_spotify_token_0.png) Open the settings and add a new *Redirect url*. Normally it is used to setup callbacks for apps, but just put `https://localhost` instead (it is mandatory as per the [authorization guide](https://developer.spotify.com/documentation/general/guides/authorization-guide/), even if not used). Forge the authorization url with your `client_id` and the encoded `redirect_uri` you whitelisted, and access it from your browser: ``` https://accounts.spotify.com/authorize?client_id=********&response_type=code&scope=user-read-recently-played%20user-top-read&redirect_uri=https%3A%2F%2Flocalhost ``` When prompted, authorize application. ![Authorize application](/.github/readme/imgs/plugin_music_recent_spotify_token_1.png) Once redirected to `redirect_uri`, extract the generated authorization `code` from your url bar. ![Extract authorization code from url](/.github/readme/imgs/plugin_music_recent_spotify_token_2.png) Go back to developer dashboard tab, and open the web console of your browser to paste the following JavaScript code, with your own `client_id`, `client_secret`, authorization `code` and `redirect_uri`. ```js (async () => { console.log(await (await fetch("https://accounts.spotify.com/api/token", { method:"POST", headers:{"Content-Type":"application/x-www-form-urlencoded"}, body:new URLSearchParams({ grant_type:"authorization_code", redirect_uri:"https://localhost", client_id:"********", client_secret:"********", code:"********", }) })).json()) })() ``` It should return a JSON response with the following content: ```json { "access_token":"********", "expires_in": 3600, "scope":"user-read-recently-played user-top-read", "token_type":"Bearer", "refresh_token":"********" } ``` Register your `client_id`, `client_secret` and `refresh_token` in secrets to finish setup. ### 🔗 Get an embed playlist url for `plugin_music_playlist` Connect to [spotify.com](https://www.spotify.com) and select the playlist you want to share. From `...` menu, select `Share` and `Copy embed code`. ![Copy embed code of playlist](/.github/readme/imgs/plugin_music_playlist_spotify.png) Extract the source link from the code pasted in your clipboard: ```html ``` ## 🍎 Apple Music ### 🗝️ Obtaining a token *(Not available)* > 😥 Unfortunately I wasn't able to find a workaround to avoid paying the $99 fee for the developer program, even using workarounds like *smart playlists*, *shortcuts* and other stuff. However if you really want this feature, you could [sponsor me](github.com/sponsors/lowlighter) and I could eventually invest in a developer account with enough money, implement it and also eventually offer service on the shared instance ### 🔗 Get an embed playlist url for `plugin_music_playlist` Connect to [music.apple.com](https://music.apple.com/) and select the playlist you want to share. From `...` menu, select `Share` and `Copy embed code`. ![Copy embed code of playlist](/.github/readme/imgs/plugin_music_playlist_apple.png) Extract the source link from the code pasted in your clipboard: ```html ``` ## ⏯️ Youtube Music ### 🗝️ Obtaining a token Login to [YouTube Music](https://music.youtube.com) on any modern browser. Open the developer tools (Ctrl-Shift-I) and select the “Network” tab ![Open developer tools](/.github/readme/imgs/plugin_music_recent_youtube_cookie_1.png) Find an authenticated POST request. The simplest way is to filter by /browse using the search bar of the developer tools. If you don’t see the request, try scrolling down a bit or clicking on the library button in the top bar. Click on the Name of any matching request. In the “Headers” tab, scroll to the “Cookie” and copy this by right-clicking on it and selecting “Copy value”. ![Copy cookie value](/.github/readme/imgs/plugin_music_recent_youtube_cookie_2.png) ### 🔗 Get an embed playlist url for `plugin_music_playlist` Extract the *playlist* URL of the playlist you want to share. Connect to [music.youtube.com](https://music.youtube.com) and select the playlist you want to share. Extract the source link from the code pasted in your clipboard: ``` https://music.youtube.com/playlist?list=******** ``` ## 📻 Last.fm ### 🗝️ Obtaining a token [Create an API account](https://www.last.fm/api/account/create) or [use an existing one](https://www.last.fm/api/accounts) to obtain a Last.fm API key. ### 🔗 Get an embed playlist url for `plugin_music_playlist` *(Not available)* ## ℹ️ Examples workflows ```yaml name: Apple Music - Random track from playlist uses: lowlighter/metrics@latest with: filename: metrics.plugin.music.playlist.svg token: NOT_NEEDED base: "" plugin_music: yes plugin_music_playlist: https://embed.music.apple.com/fr/playlist/usr-share/pl.u-V9D7m8Etjmjd0D plugin_music_limit: 2 ``` ```yaml name: Spotify - Random track from playlist uses: lowlighter/metrics@latest with: filename: metrics.plugin.music.playlist.spotify.svg token: NOT_NEEDED base: "" plugin_music: yes plugin_music_playlist: https://open.spotify.com/embed/playlist/3nfA87oeJw4LFVcUDjRcqi ``` ```yaml name: Spotify - Recently listed uses: lowlighter/metrics@latest with: filename: metrics.plugin.music.recent.svg token: NOT_NEEDED base: "" plugin_music: yes plugin_music_provider: spotify plugin_music_mode: recent plugin_music_token: ${{ secrets.SPOTIFY_TOKENS }} plugin_music_limit: 2 ``` ```yaml name: Spotify - Top tracks uses: lowlighter/metrics@latest with: token: NOT_NEEDED base: "" plugin_music: yes plugin_music_mode: top plugin_music_provider: spotify plugin_music_token: ${{ secrets.SPOTIFY_TOKENS }} plugin_music_time_range: short plugin_music_top_type: tracks ``` ```yaml name: Spotify - Top artists uses: lowlighter/metrics@latest with: token: NOT_NEEDED base: "" plugin_music: yes plugin_music_mode: top plugin_music_provider: spotify plugin_music_token: ${{ secrets.SPOTIFY_TOKENS }} plugin_music_time_range: long plugin_music_top_type: artists ``` ```yaml name: Youtube Music - Random track from playlist uses: lowlighter/metrics@latest with: token: NOT_NEEDED base: "" plugin_music: yes plugin_music_playlist: >- https://music.youtube.com/playlist?list=OLAK5uy_kU_uxp9TUOl9zVdw77xith8o9AknVwz9U ``` ```yaml name: Youtube Music - Recently listed uses: lowlighter/metrics@latest with: token: NOT_NEEDED base: "" plugin_music_token: ${{ secrets.YOUTUBE_MUSIC_TOKENS }} plugin_music: yes plugin_music_mode: recent plugin_music_provider: youtube ``` ```yaml name: Last.fm - Recently listed uses: lowlighter/metrics@latest with: token: NOT_NEEDED base: "" plugin_music_token: ${{ secrets.LASTFM_TOKEN }} plugin_music: yes plugin_music_provider: lastfm plugin_music_user: RJ ```