diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index ffd0ccd76..f7162f557 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -37,7 +37,8 @@ "openApplicationDirectory": "open application directory", "openIn": { "lastfm": "Open in Last.fm", - "musicbrainz": "Open in MusicBrainz" + "musicbrainz": "Open in MusicBrainz", + "spotify": "Open in Spotify" } }, "common": { @@ -924,6 +925,10 @@ "mpvExtraParameters_help": "one per line", "musicbrainz_description": "show links to MusicBrainz on artist/album pages, where MusicBrainz ID exists", "musicbrainz": "show MusicBrainz links", + "spotify_description": "show links to Spotify on artist/album pages", + "spotify": "show Spotify links", + "nativeSpotify_description": "open in the Spotify app instead of your browser", + "nativeSpotify": "use Spotify app", "neteaseTranslation_description": "When enabled, fetches and displays translated lyrics from NetEase if available", "neteaseTranslation": "Enable NetEase translations", "notify": "enable song notifications", diff --git a/src/renderer/features/albums/components/album-detail-content.tsx b/src/renderer/features/albums/components/album-detail-content.tsx index 51886c9ae..56961d860 100644 --- a/src/renderer/features/albums/components/album-detail-content.tsx +++ b/src/renderer/features/albums/components/album-detail-content.tsx @@ -298,6 +298,8 @@ interface AlbumMetadataExternalLinksProps { lastFM: boolean; mbzId?: null | string; musicBrainz: boolean; + nativeSpotify: boolean; + spotify: boolean; } const AlbumMetadataExternalLinks = ({ @@ -307,10 +309,12 @@ const AlbumMetadataExternalLinks = ({ lastFM, mbzId, musicBrainz, + nativeSpotify, + spotify, }: AlbumMetadataExternalLinksProps) => { const { t } = useTranslation(); - if (!externalLinks || (!lastFM && !musicBrainz)) return null; + if (!externalLinks || (!lastFM && !musicBrainz && !spotify)) return null; return ( @@ -358,6 +362,28 @@ const AlbumMetadataExternalLinks = ({ variant="subtle" /> ) : null} + {spotify && ( + + )} ); @@ -370,7 +396,7 @@ export const AlbumDetailContent = () => { albumQueries.detail({ query: { id: albumId }, serverId: server.id }), ); - const { externalLinks, lastFM, musicBrainz } = useExternalLinks(); + const { externalLinks, lastFM, musicBrainz, nativeSpotify, spotify } = useExternalLinks(); const comment = detailQuery?.data?.comment; @@ -403,6 +429,8 @@ export const AlbumDetailContent = () => { lastFM={lastFM} mbzId={mbzId || undefined} musicBrainz={musicBrainz} + nativeSpotify={nativeSpotify} + spotify={spotify} /> diff --git a/src/renderer/features/artists/components/album-artist-detail-content.tsx b/src/renderer/features/artists/components/album-artist-detail-content.tsx index 1918be81a..76c0740ba 100644 --- a/src/renderer/features/artists/components/album-artist-detail-content.tsx +++ b/src/renderer/features/artists/components/album-artist-detail-content.tsx @@ -890,7 +890,9 @@ interface AlbumArtistMetadataExternalLinksProps { lastFM: boolean; mbzId?: null | string; musicBrainz: boolean; + nativeSpotify: boolean; order?: number; + spotify: boolean; } const AlbumArtistMetadataExternalLinks = ({ @@ -899,11 +901,13 @@ const AlbumArtistMetadataExternalLinks = ({ lastFM, mbzId, musicBrainz, + nativeSpotify, order, + spotify, }: AlbumArtistMetadataExternalLinksProps) => { const { t } = useTranslation(); - if (!externalLinks || (!lastFM && !musicBrainz)) return null; + if (!externalLinks || (!lastFM && !musicBrainz && !spotify)) return null; return ( @@ -948,6 +952,27 @@ const AlbumArtistMetadataExternalLinks = ({ variant="subtle" /> ) : null} + {spotify && ( + + )} @@ -1050,7 +1075,7 @@ export const AlbumArtistDetailContent = ({ }: AlbumArtistDetailContentProps) => { const artistItems = useArtistItems(); const artistRadioCount = useArtistRadioCount(); - const { externalLinks, lastFM, musicBrainz } = useExternalLinks(); + const { externalLinks, lastFM, musicBrainz, nativeSpotify, spotify } = useExternalLinks(); const { albumArtistId, artistId } = useParams() as { albumArtistId?: string; artistId?: string; @@ -1136,14 +1161,16 @@ export const AlbumArtistDetailContent = ({ genres={detailQuery.data?.genres} order={genresOrder} /> - {externalLinks && (lastFM || musicBrainz) && ( + {externalLinks && (lastFM || musicBrainz || spotify) && ( )} {enabledItem.biography && ( diff --git a/src/renderer/features/settings/components/general/application-settings.tsx b/src/renderer/features/settings/components/general/application-settings.tsx index 5c4e9692c..c7172b4db 100644 --- a/src/renderer/features/settings/components/general/application-settings.tsx +++ b/src/renderer/features/settings/components/general/application-settings.tsx @@ -601,6 +601,48 @@ export const ApplicationSettings = memo(() => { isHidden: !settings.externalLinks, title: t('setting.musicbrainz', { postProcess: 'sentenceCase' }), }, + { + control: ( + { + setSettings({ + general: { + ...settings, + spotify: e.currentTarget.checked, + }, + }); + }} + /> + ), + description: t('setting.spotify', { + context: 'description', + postProcess: 'sentenceCase', + }), + isHidden: !settings.externalLinks, + title: t('setting.spotify', { postProcess: 'sentenceCase' }), + }, + { + control: ( + { + setSettings({ + general: { + ...settings, + nativeSpotify: e.currentTarget.checked, + }, + }); + }} + /> + ), + description: t('setting.nativeSpotify', { + context: 'description', + postProcess: 'sentenceCase', + }), + isHidden: !settings.externalLinks || !settings.spotify, + title: t('setting.nativeSpotify', { postProcess: 'sentenceCase' }), + }, { control: ( externalLinks: state.general.externalLinks, lastFM: state.general.lastFM, musicBrainz: state.general.musicBrainz, + nativeSpotify: state.general.nativeSpotify, + spotify: state.general.spotify, }), shallow, ); diff --git a/src/shared/components/icon/icon.tsx b/src/shared/components/icon/icon.tsx index 6358dda07..349978e18 100644 --- a/src/shared/components/icon/icon.tsx +++ b/src/shared/components/icon/icon.tsx @@ -125,7 +125,7 @@ import { import { MdOutlineVisibility, MdOutlineVisibilityOff } from 'react-icons/md'; import { PiMouseLeftClickFill, PiMouseRightClickFill } from 'react-icons/pi'; import { RiPlayListAddLine, RiRepeat2Line, RiRepeatOneLine } from 'react-icons/ri'; -import { SiMusicbrainz } from 'react-icons/si'; +import { SiMusicbrainz, SiSpotify } from 'react-icons/si'; import styles from './icon.module.css'; @@ -156,6 +156,7 @@ export const AppIcon = { brandGitHub: LuGithub, brandLastfm: FaLastfmSquare, brandMusicBrainz: SiMusicbrainz, + brandSpotify: SiSpotify, cache: LuCloudDownload, check: LuCheck, clipboardCopy: LuClipboardCopy,