@unavatar/core 3.26.0 → 3.28.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/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.26.0",
5
+ "version": "3.28.0",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
@@ -0,0 +1,15 @@
1
+ 'use strict'
2
+
3
+ const getAvatarUrl = input =>
4
+ `https://cults3d.com/en/users/${
5
+ input.startsWith('@') ? input.slice(1) : input
6
+ }`
7
+
8
+ module.exports = ({ createHtmlProvider, getOgImage }) =>
9
+ createHtmlProvider({
10
+ name: 'cults3d',
11
+ url: getAvatarUrl,
12
+ getter: getOgImage
13
+ })
14
+
15
+ module.exports.getAvatarUrl = getAvatarUrl
@@ -0,0 +1,36 @@
1
+ 'use strict'
2
+
3
+ const HUGGINGFACE_API_URL = 'https://huggingface.co/api'
4
+
5
+ const getUserOverviewUrl = input =>
6
+ `${HUGGINGFACE_API_URL}/users/${encodeURIComponent(input)}/overview`
7
+
8
+ const getOrganizationOverviewUrl = input =>
9
+ `${HUGGINGFACE_API_URL}/organizations/${encodeURIComponent(input)}/overview`
10
+
11
+ const fetchAvatarUrl = async ({ got, url }) => {
12
+ const { statusCode, body } = await got(url, {
13
+ responseType: 'json',
14
+ throwHttpErrors: false
15
+ })
16
+
17
+ if (statusCode >= 400) return
18
+ return typeof body?.avatarUrl === 'string' ? body.avatarUrl : undefined
19
+ }
20
+
21
+ module.exports = ({ got }) =>
22
+ async function huggingface (input) {
23
+ const userAvatarUrl = await fetchAvatarUrl({
24
+ got,
25
+ url: getUserOverviewUrl(input)
26
+ })
27
+ if (userAvatarUrl) return userAvatarUrl
28
+
29
+ return fetchAvatarUrl({
30
+ got,
31
+ url: getOrganizationOverviewUrl(input)
32
+ })
33
+ }
34
+
35
+ module.exports.getOrganizationOverviewUrl = getOrganizationOverviewUrl
36
+ module.exports.getUserOverviewUrl = getUserOverviewUrl
@@ -8,6 +8,7 @@ const providersBy = {
8
8
  'behance',
9
9
  'bluesky',
10
10
  'buymeacoffee',
11
+ 'cults3d',
11
12
  'deviantart',
12
13
  'discord',
13
14
  'dribbble',
@@ -16,6 +17,7 @@ const providersBy = {
16
17
  'github',
17
18
  'gitlab',
18
19
  'google-play',
20
+ 'huggingface',
19
21
  'instagram',
20
22
  'ko-fi',
21
23
  'linkedin',
@@ -55,6 +57,7 @@ module.exports = ctx => {
55
57
  behance: require('./behance')(ctx),
56
58
  bluesky: require('./bluesky')(ctx),
57
59
  buymeacoffee: require('./buymeacoffee')(ctx),
60
+ cults3d: require('./cults3d')(ctx),
58
61
  deviantart: require('./deviantart')(ctx),
59
62
  discord: require('./discord')(ctx),
60
63
  dribbble: require('./dribbble')(ctx),
@@ -66,6 +69,7 @@ module.exports = ctx => {
66
69
  google: require('./google')(ctx),
67
70
  'google-play': require('./google-play')(ctx),
68
71
  gravatar: require('./gravatar')(ctx),
72
+ huggingface: require('./huggingface')(ctx),
69
73
  instagram: require('./instagram')(ctx),
70
74
  'ko-fi': require('./ko-fi')(ctx),
71
75
  linkedin: require('./linkedin')(ctx),