From 5855682e47c4b89970f242263331517f53e42d81 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Sun, 16 Jan 2022 08:50:11 -0500 Subject: [PATCH] doc(plugins/music): update --- source/plugins/music/README.md | 458 ++++++++++++++---------------- source/plugins/music/metadata.yml | 100 ++++--- 2 files changed, 278 insertions(+), 280 deletions(-) diff --git a/source/plugins/music/README.md b/source/plugins/music/README.md index b4d7579f..ae6df3a3 100644 --- a/source/plugins/music/README.md +++ b/source/plugins/music/README.md @@ -1,125 +1,182 @@ -### 🎼 Music plugin - -The *music* plugin lets you display : - + - + + + + + + + + + + + + + + +
-
Random tracks from a playlist - -
-
Recently listened - -
- -

🎼 Music plugin

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

+

Different music providers are supported.

+
Supported features
β†’ Full specification
πŸ“— Classic template
πŸ‘€ Users πŸ‘₯ Organizations
πŸ—οΈ plugin_music_token
+
Random tracks from a playlist
+
Recently listened
+ +
+ -It can work in the following modes: +#### ➑️ Available options -### Playlist mode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeDescription
plugin_music

Enable music plugin

+
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)

+
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
+type: token +
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 specifed, the default value is playlist, else it is recent

+
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)

+
type: string +
plugin_music_limit

Display limit

+
type: number +(1 ≀ +π‘₯ +≀ 100) +
+default: 4
plugin_music_played_at

Recently played - Toggle last played timestamp display

+
type: boolean +
+default: no
plugin_music_time_range

Top tracks - Time range for top mode

+
    +
  • short: 4 weeks
  • +
  • medium: 6 months
  • +
  • long: several years
  • +
+
type: string +
+default: short
+allowed values:
  • short
  • medium
  • long
plugin_music_top_type

Top tracks - Display type

+
    +
  • tracks: display track
  • +
  • artists: display artists
  • +
+
type: string +
+default: tracks
+allowed values:
  • tracks
  • artists
plugin_music_user

Music provider username

+
type: string +
+default: β†’ User login
+ -Select randomly a few tracks from a given playlist to share your favorites tracks with your visitors. - -Select a music provider below for instructions. - -
-Apple Music - -Extract the *embed* URL of the playlist you want to share. - -To do so, 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 - -``` - -And use this value in `plugin_music_playlist` option. - -
- -
-Spotify - -Extract the *embed* URL of the playlist you want to share. - -To do so, Open Spotify 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 - -``` - -And use this value in `plugin_music_playlist` option. - -
- -
-Last.fm - -This mode is not supported for now. - -
- -
-YouTube Music - -Extract the *playlist* URL of the playlist you want to share. - -To do so, Open YouTube Music and select the playlist you want to share. - -Extract the source link from copying it from the address bar: -``` -https://music.youtube.com/playlist?list=******** -``` - -And use this value in `plugin_music_playlist` option. - -
- -#### ℹ️ Examples workflows - -[➑️ Available options for this plugin](metadata.yml) - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - plugin_music: yes - plugin_music_limit: 4 # Limit to 4 entries - plugin_music_playlist: https://******** # Use extracted playlist link - # plugin_music_provider: (will be guessed through plugin_music_playlist) - # plugin_music_mode: (will be set to "playlist" when plugin_music_playlist is provided) -``` - -### Recently played & top modes - -- **Recently played**: Display tracks you have played recently. -- **Top**: Display your top artists/tracks for a certain time period. +## 🎺 Configuring music provider Select a music provider below for additional instructions. -
-Apple Music +## πŸŽ™οΈ Spotify -This mode is not supported for now. +### πŸ—οΈ Obtaining a token -I tried to find a way with *smart playlists*, *shortcuts* and other stuff but could not figure a workaround to do it without paying the $99 fee for the developer program. - -So unfortunately this isn't available for now. - -
- -
-Spotify - -Spotify does not have *personal tokens*, so it makes the process a bit longer because you're 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`. +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. @@ -134,7 +191,7 @@ Forge the authorization url with your `client_id` and the encoded `redirect_uri` 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 your application. +When prompted, authorize application. ![Authorize application](/.github/readme/imgs/plugin_music_recent_spotify_token_1.png) @@ -142,7 +199,7 @@ Once redirected to `redirect_uri`, extract the generated authorization `code` fr ![Extract authorization code from url](/.github/readme/imgs/plugin_music_recent_spotify_token_2.png) -Go back to your 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`. +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 () => { @@ -173,25 +230,43 @@ It should return a JSON response with the following content: Register your `client_id`, `client_secret` and `refresh_token` in secrets to finish setup. -
+### πŸ”— Get an embed playlist url for `plugin_music_playlist` -
-Last.fm +Connect to [spotify.com](https://www.spotify.com) and select the playlist you want to share. +From `...` menu, select `Share` and `Copy embed code`. -Obtain a Last.fm API key. +![Copy embed code of playlist](/.github/readme/imgs/plugin_music_playlist_spotify.png) -To do so, you can simply [create an API account](https://www.last.fm/api/account/create) or [use an existing one](https://www.last.fm/api/accounts). +Extract the source link from the code pasted in your clipboard: +```html + +``` -Register your API key to finish setup. +## 🍎 Apple Music -
+### πŸ—οΈ Obtaining a token -
-YouTube Music +*(Not available)* -Extract your YouTube Music cookies. +> πŸ˜₯ 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 developper account with enough money, implement it and also eventually offer service on the shared instance -To do so, open [YouTube Music](https://music.youtube.com) (whilst logged in) on any modern browser +### πŸ”— 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 @@ -203,125 +278,28 @@ Click on the Name of any matching request. In the β€œHeaders” tab, scroll to t ![Copy cookie value](/.github/readme/imgs/plugin_music_recent_youtube_cookie_2.png) -
+### πŸ”— Get an embed playlist url for `plugin_music_playlist` -#### ➑️ Available options +Extract the *playlist* URL of the playlist you want to share. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TypeDescription
plugin_music

Display your music tracks

-
type: boolean -
-default: no
plugin_music_provider

Music provider

-
type: string -
-allowed values:
  • apple
  • spotify
  • lastfm
  • youtube
plugin_music_token

Music provider personal token

-
πŸ” Token
-type: token -
plugin_music_mode

Plugin mode

-
type: string -
-allowed values:
  • playlist
  • recent
  • top
plugin_music_playlist

Embed playlist url

-
type: string -
plugin_music_limit

Maximum number of tracks to display

-
type: number -(1 ≀ -π‘₯ -≀ 100) -
-default: 4
plugin_music_played_at

Display when the track was played

-
type: boolean -
-default: no
plugin_music_time_range

Time period for top mode

-
type: string -
-default: short
-allowed values:
  • short
  • medium
  • long
plugin_music_top_type

Whether to show tracks or artists in top mode

-
type: string -
-default: tracks
-allowed values:
  • tracks
  • artists
plugin_music_user

Music provider username

-
type: string -
-default: β†’ User login
- +Connect to [music.youtube.com](https://music.youtube.com) and select the playlist you want to share. -*[β†’ Full specification](metadata.yml)* +Extract the source link from the code pasted in your clipboard: +``` +https://music.youtube.com/playlist?list=******** +``` -#### ℹ️ Examples workflows +## πŸ“» 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 diff --git a/source/plugins/music/metadata.yml b/source/plugins/music/metadata.yml index dbbec351..4c79930b 100644 --- a/source/plugins/music/metadata.yml +++ b/source/plugins/music/metadata.yml @@ -1,5 +1,12 @@ name: "🎼 Music plugin" category: social +description: | + This plugin can display top and recently listened music tracks or from a random playlist. + + Different music providers are supported. +examples: + +random tracks from a playlist: https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.music.playlist.svg + +recently listened: https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.music.recent.svg index: 2 supports: - user @@ -7,87 +14,100 @@ supports: scopes: [] inputs: - # Enable or disable plugin plugin_music: - description: Display your music tracks + description: Enable music plugin type: boolean default: no - # Name of music provider - # This is optional for "playlist" mode (it can be deduced automatically from "plugin_music_playlist" url) - # This is required in other modes plugin_music_provider: - description: Music provider + description: | + 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) type: string default: "" values: - - apple # Apple Music - - spotify # Spotify - - lastfm # Last.fm - - youtube # YouTube + - apple + - spotify + - lastfm + - youtube - # Music provider token - # This may be required depending on music provider used and plugin mode - # - "apple" : not required - # - "spotify" : required for "recent" or "top" mode, format is "client_id, client_secret, refresh_token" - # - "lastfm" : required, format is "api_key" - # - "youtube" : required for "recent" mode, format is "cookie" plugin_music_token: - description: Music provider personal token + description: | + 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" type: token default: "" - # Plugin mode plugin_music_mode: - description: Plugin mode - type: string - default: "" # Defaults to "recent" or to "playlist" if "plugin_music_playlist" is specified - values: - - playlist # Display tracks from an embed playlist randomly - - recent # Display recently listened tracks - - top # Display top listened artists/tracks + description: | + 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 specifed, the default value is `playlist`, else it is `recent` + type: string + default: "" + values: + - playlist + - recent + - top - # Embed playlist url (i.e. url used by music player iframes) plugin_music_playlist: - description: Embed playlist url + description: | + Playlist URL + + It must be from an "embed url" (i.e. music player iframes that can be integrated in other websites) type: string default: "" example: https://embed.music.apple.com/--/playlist/--------/-------- - # Number of music tracks to display plugin_music_limit: - description: Maximum number of tracks to display + description: Display limit type: number default: 4 min: 1 max: 100 - # Display when track was last played plugin_music_played_at: - description: Display when the track was played + description: Recently played - Toggle last played timestamp display type: boolean default: no - # Time range for "top" mode plugin_music_time_range: - description: Time period for top mode + description: | + Top tracks - Time range for `top` mode + - `short`: 4 weeks + - `medium`: 6 months + - `long`: several years type: string - default: short # Defaults to "short" (4 weeks) + default: short values: - - short # Top artists/tracks from past 4 weeks - - medium # Top artists/tracks from past 6 months - - long # Top artists/tracks from several years + - short + - medium + - long - # Option for "top" mode to select tracks or artists plugin_music_top_type: - description: Whether to show tracks or artists in top mode + description: | + Top tracks - Display type + - `tracks`: display track + - `artists`: display artists type: string default: tracks values: - tracks - artists - # Username on music provider service plugin_music_user: description: Music provider username type: string