@unavatar/core 3.42.1 → 3.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,6 +25,7 @@
25
25
  - [CodePen](#codepen)
26
26
  - [Cults3D](#cults3d)
27
27
  - [Cursor](#cursor)
28
+ - [Deezer](#deezer)
28
29
  - [DeviantArt](#deviantart)
29
30
  - [Discord](#discord)
30
31
  - [Docker Hub](#docker-hub)
@@ -68,6 +69,7 @@
68
69
  - [Telegram](#telegram)
69
70
  - [Thingiverse](#thingiverse)
70
71
  - [Threads](#threads)
72
+ - [TIDAL](#tidal)
71
73
  - [TikTok](#tiktok)
72
74
  - [Tumblr](#tumblr)
73
75
  - [Twitch](#twitch)
@@ -595,6 +597,21 @@ Get any Cursor user's profile picture by their username.
595
597
 
596
598
  e.g., [unavatar.io/cursor/leerob](https://unavatar.io/cursor/leerob)
597
599
 
600
+ ### Deezer
601
+
602
+ Get artwork for any Deezer entity — artists, albums, playlists, or tracks. Look up by Deezer ID.
603
+
604
+ By default the input is treated as an artist:
605
+
606
+ e.g., [unavatar.io/deezer/27](https://unavatar.io/deezer/27)
607
+
608
+ The input also supports a URI format `type:id`:
609
+
610
+ - `artist` (default): [unavatar.io/deezer/artist:27](https://unavatar.io/deezer/artist:27)
611
+ - `album`: [unavatar.io/deezer/album:302127](https://unavatar.io/deezer/album:302127)
612
+ - `playlist`: [unavatar.io/deezer/playlist:908622995](https://unavatar.io/deezer/playlist:908622995)
613
+ - `track`: [unavatar.io/deezer/track:3135556](https://unavatar.io/deezer/track:3135556)
614
+
598
615
  ### DeviantArt
599
616
 
600
617
  Get any DeviantArt user's profile picture by their username.
@@ -945,6 +962,22 @@ Get any Threads user's profile picture by their username.
945
962
 
946
963
  e.g., [unavatar.io/threads/zuck](https://unavatar.io/threads/zuck)
947
964
 
965
+ ### TIDAL
966
+
967
+ Get artwork for any TIDAL entity — artists, albums, playlists, tracks, or videos. Look up by TIDAL ID.
968
+
969
+ By default the input is treated as an artist:
970
+
971
+ e.g., [unavatar.io/tidal/1566](https://unavatar.io/tidal/1566)
972
+
973
+ The input also supports a URI format `type:id`:
974
+
975
+ - `artist` (default): [unavatar.io/tidal/artist:1566](https://unavatar.io/tidal/artist:1566)
976
+ - `album`: [unavatar.io/tidal/album:1765857](https://unavatar.io/tidal/album:1765857)
977
+ - `playlist`: [unavatar.io/tidal/playlist:c3c18106-c4f5-4021-bb18-108255c1f450](https://unavatar.io/tidal/playlist:c3c18106-c4f5-4021-bb18-108255c1f450)
978
+ - `track`: [unavatar.io/tidal/track:113655761](https://unavatar.io/tidal/track:113655761)
979
+ - `video`: [unavatar.io/tidal/video:45323542](https://unavatar.io/tidal/video:45323542)
980
+
948
981
  ### TikTok
949
982
 
950
983
  Get any TikTok user's profile picture by their username. No authentication or API tokens needed — just pass the username.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@unavatar/core",
3
3
  "description": "Get unified user avatar from social networks, including Instagram, SoundCloud, Telegram, Twitter, YouTube & more.",
4
4
  "homepage": "https://unavatar.io",
5
- "version": "3.42.1",
5
+ "version": "3.44.0",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
@@ -0,0 +1,32 @@
1
+ 'use strict'
2
+
3
+ // Entities without artwork keep an empty image hash
4
+ // (cdn-images.dzcdn.net/images/artist//500x500.jpg), which resolves to a
5
+ // generic placeholder, so any empty hash segment is treated as a miss.
6
+ const isArtwork = url => !/\/images\/[^/]+\/\/\d/.test(url)
7
+
8
+ const getAvatarUrl = input => {
9
+ const [first, second] = input.split(':')
10
+ const type = second ? first : 'artist'
11
+ const id = second ?? first
12
+ return `https://www.deezer.com/en/${type}/${id}`
13
+ }
14
+
15
+ // Deezer server-renders og:image for missing entities as well, so the empty
16
+ // placeholder is filtered out and everything else is returned as-is.
17
+ const getAvatar = ({ $, getOgImage, NOT_FOUND }) => {
18
+ const image = getOgImage($)
19
+ return image && isArtwork(image) ? image : NOT_FOUND
20
+ }
21
+
22
+ const factory = ({ createHtmlProvider, getOgImage, NOT_FOUND }) =>
23
+ createHtmlProvider({
24
+ name: 'deezer',
25
+ url: getAvatarUrl,
26
+ getter: $ => getAvatar({ $, getOgImage, NOT_FOUND })
27
+ })
28
+
29
+ factory.getAvatarUrl = getAvatarUrl
30
+ factory.getAvatar = getAvatar
31
+
32
+ module.exports = factory
@@ -12,6 +12,7 @@ const providersBy = {
12
12
  'codepen',
13
13
  'cults3d',
14
14
  'cursor',
15
+ 'deezer',
15
16
  'deviantart',
16
17
  'discord',
17
18
  'dockerhub',
@@ -51,6 +52,7 @@ const providersBy = {
51
52
  'telegram',
52
53
  'thingiverse',
53
54
  'threads',
55
+ 'tidal',
54
56
  'tiktok',
55
57
  'tumblr',
56
58
  'twitch',
@@ -75,6 +77,7 @@ module.exports = ctx => {
75
77
  codepen: require('./codepen')(ctx),
76
78
  cults3d: require('./cults3d')(ctx),
77
79
  cursor: require('./cursor')(ctx),
80
+ deezer: require('./deezer')(ctx),
78
81
  deviantart: require('./deviantart')(ctx),
79
82
  discord: require('./discord')(ctx),
80
83
  dockerhub: require('./dockerhub')(ctx),
@@ -118,6 +121,7 @@ module.exports = ctx => {
118
121
  telegram: require('./telegram')(ctx),
119
122
  thingiverse: require('./thingiverse')(ctx),
120
123
  threads: require('./threads')(ctx),
124
+ tidal: require('./tidal')(ctx),
121
125
  tiktok: require('./tiktok')(ctx),
122
126
  tumblr: require('./tumblr')(ctx),
123
127
  twitch: require('./twitch')(ctx),
@@ -0,0 +1,35 @@
1
+ 'use strict'
2
+
3
+ // Real artwork is served from resources.tidal.com. When an entity has no
4
+ // artwork the page keeps a generic share image (tidal.com/img/FB_…), so
5
+ // anything off the resources host is treated as a miss.
6
+ const isArtwork = url => /^https:\/\/resources\.tidal\.com\//.test(url)
7
+
8
+ const getAvatarUrl = input => {
9
+ const [first, second] = input.split(':')
10
+ const type = second ? first : 'artist'
11
+ const id = second ?? first
12
+ return `https://tidal.com/${type}/${id}`
13
+ }
14
+
15
+ // The static markup only ships the generic share image; the entity artwork is
16
+ // injected into og:image once the SPA hydrates, so the page must be prerendered.
17
+ const getAvatar = ({ $, getOgImage, NOT_FOUND }) => {
18
+ const image = getOgImage($)
19
+ return image && isArtwork(image) ? image : NOT_FOUND
20
+ }
21
+
22
+ const factory = ({ createHtmlProvider, getOgImage, NOT_FOUND }) =>
23
+ createHtmlProvider({
24
+ name: 'tidal',
25
+ url: getAvatarUrl,
26
+ getter: $ => getAvatar({ $, getOgImage, NOT_FOUND }),
27
+ htmlOpts: () => ({
28
+ prerender: true
29
+ })
30
+ })
31
+
32
+ factory.getAvatarUrl = getAvatarUrl
33
+ factory.getAvatar = getAvatar
34
+
35
+ module.exports = factory