Skip to content

Commit

Permalink
added new templates key
Browse files Browse the repository at this point in the history
  • Loading branch information
studiowebux committed Oct 30, 2024
1 parent acc1778 commit de005fa
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "spotify-link",
"name": "Spotify Link",
"version": "1.5.2",
"version": "1.6.0",
"minAppVersion": "0.15.0",
"description": "Include the song you're currently listening to in your note.",
"author": "Studio Webux",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spotify-link",
"version": "1.5.2",
"version": "1.6.0",
"description": "Include the song you're currently listening to in your Obsidian (https://obsidian.md) note",
"main": "main.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/settingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ export default class SettingsTab extends PluginSettingTab {
.createEl("li", { text: "{{ timestamp }}" })
.createEl("li", { text: "{{ genres }}" })
.createEl("li", { text: "{{ genres_array }}" })
.createEl("li", { text: "{{ genres_hashtag }}" });
.createEl("li", { text: "{{ genres_hashtag }}" })
.createEl("li", { text: "{{ followers }}" })
.createEl("li", { text: "{{ artist_image }}" })
.createEl("li", { text: "{{ popularity }}" })
.createEl("li", { text: "{{ artist_names }}" });

divDoc.createEl("p", { text: "Available variables (podcast):" });
divDoc
Expand Down
26 changes: 26 additions & 0 deletions src/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,31 @@ export function getTrackMessage(
)
.flat(Infinity)
.join(" "),
)
.replace(
/{{ followers }}|{{followers}}/g,
artists.length > 1
? artists
?.map((artist) => `${artist.name}: ${artist.followers.total}`)
.join(", ")
: artists[0].followers.total.toString(),
)
.replace(
/{{ popularity }}|{{popularity}}/g,
artists.length > 1
? artists
?.map((artist) => `${artist.name}: ${artist.popularity}`)
.join(", ")
: artists[0].popularity.toString(),
)
.replace(
/{{ artist_image }}|{{artist_image}}/g,
artists
?.map((artist) => `![${artist.name}](${artist.images[0].url})`)
.join(", "),
)
.replace(
/{{ artist_name }}|{{artist_name}}/g,
artists?.map((artist) => artist.name).join(", "),
);
}

0 comments on commit de005fa

Please sign in to comment.