@unavatar/core 3.51.0 → 3.54.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 +24 -0
- package/package.json +1 -1
- package/src/providers/dailymotion.js +33 -0
- package/src/providers/index.js +6 -0
- package/src/providers/keybase.js +25 -0
- package/src/providers/minecraft.js +40 -0
package/README.md
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
- [CodePen](#codepen)
|
|
32
32
|
- [Cults3D](#cults3d)
|
|
33
33
|
- [Cursor](#cursor)
|
|
34
|
+
- [Dailymotion](#dailymotion)
|
|
34
35
|
- [Deezer](#deezer)
|
|
35
36
|
- [DeviantArt](#deviantart)
|
|
36
37
|
- [Discord](#discord)
|
|
@@ -51,12 +52,14 @@
|
|
|
51
52
|
- [Hugging Face](#hugging-face)
|
|
52
53
|
- [Instagram](#instagram)
|
|
53
54
|
- [Juejin](#juejin)
|
|
55
|
+
- [Keybase](#keybase)
|
|
54
56
|
- [Kick](#kick)
|
|
55
57
|
- [Ko-fi](#ko-fi)
|
|
56
58
|
- [LinkedIn](#linkedin)
|
|
57
59
|
- [Mastodon](#mastodon)
|
|
58
60
|
- [Medium](#medium)
|
|
59
61
|
- [Microlink](#microlink)
|
|
62
|
+
- [Minecraft](#minecraft)
|
|
60
63
|
- [NetEase Music](#netease-music)
|
|
61
64
|
- [npm](#npm)
|
|
62
65
|
- [OnlyFans](#onlyfans)
|
|
@@ -647,6 +650,12 @@ Get any Cursor user's profile picture by their username.
|
|
|
647
650
|
|
|
648
651
|
e.g., [unavatar.io/cursor/leerob](https://unavatar.io/cursor/leerob)
|
|
649
652
|
|
|
653
|
+
### Dailymotion
|
|
654
|
+
|
|
655
|
+
Get any Dailymotion user's profile picture by their username or user ID.
|
|
656
|
+
|
|
657
|
+
e.g., [unavatar.io/dailymotion/dailymotion](https://unavatar.io/dailymotion/dailymotion)
|
|
658
|
+
|
|
650
659
|
### Deezer
|
|
651
660
|
|
|
652
661
|
Get artwork for any Deezer artist, album, playlist, or track by ID.
|
|
@@ -831,6 +840,12 @@ Get any Juejin user's profile picture by their numeric user ID.
|
|
|
831
840
|
|
|
832
841
|
e.g., [unavatar.io/juejin/1556564194374926](https://unavatar.io/juejin/1556564194374926)
|
|
833
842
|
|
|
843
|
+
### Keybase
|
|
844
|
+
|
|
845
|
+
Get any Keybase user's profile picture by their username.
|
|
846
|
+
|
|
847
|
+
e.g., [unavatar.io/keybase/chris](https://unavatar.io/keybase/chris)
|
|
848
|
+
|
|
834
849
|
### Kick
|
|
835
850
|
|
|
836
851
|
Get any Kick streamer's profile picture by their username.
|
|
@@ -872,6 +887,15 @@ Extract the logo or representative image from any URL. The page is rendered and
|
|
|
872
887
|
|
|
873
888
|
e.g., [unavatar.io/microlink/microlink.io](https://unavatar.io/microlink/microlink.io)
|
|
874
889
|
|
|
890
|
+
### Minecraft
|
|
891
|
+
|
|
892
|
+
Get any Minecraft Java Edition player's face by their username or UUID. The player is resolved through Mojang first, so unknown players return no avatar, and the face is rendered by [mc-heads.net](https://mc-heads.net).
|
|
893
|
+
|
|
894
|
+
Available inputs:
|
|
895
|
+
|
|
896
|
+
- Username, e.g., [unavatar.io/minecraft/notch](https://unavatar.io/minecraft/notch)
|
|
897
|
+
- UUID, with or without dashes, e.g., [unavatar.io/minecraft/069a79f4-44e9-4726-a5be-fca90e38aaf5](https://unavatar.io/minecraft/069a79f4-44e9-4726-a5be-fca90e38aaf5)
|
|
898
|
+
|
|
875
899
|
### NetEase Music
|
|
876
900
|
|
|
877
901
|
Get any NetEase Music user's profile picture by their numeric user ID.
|
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.
|
|
5
|
+
"version": "3.54.0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const API_URL = 'https://api.dailymotion.com/user'
|
|
4
|
+
|
|
5
|
+
const PLACEHOLDER_AVATAR_PATH_PREFIX = '/d/'
|
|
6
|
+
|
|
7
|
+
const isPlaceholderAvatar = url =>
|
|
8
|
+
new URL(url).pathname.startsWith(PLACEHOLDER_AVATAR_PATH_PREFIX)
|
|
9
|
+
|
|
10
|
+
const getAvatarUrl = input =>
|
|
11
|
+
`${API_URL}/${encodeURIComponent(input)}?fields=avatar_720_url`
|
|
12
|
+
|
|
13
|
+
const getAvatar = body => {
|
|
14
|
+
const url = body?.avatar_720_url
|
|
15
|
+
return typeof url === 'string' && url && !isPlaceholderAvatar(url)
|
|
16
|
+
? url
|
|
17
|
+
: undefined
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = ({ got }) =>
|
|
21
|
+
async function dailymotion (input) {
|
|
22
|
+
const { body, statusCode } = await got(getAvatarUrl(input), {
|
|
23
|
+
responseType: 'json',
|
|
24
|
+
throwHttpErrors: false
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
if (statusCode >= 400) return
|
|
28
|
+
|
|
29
|
+
return getAvatar(body)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
33
|
+
module.exports.getAvatar = getAvatar
|
package/src/providers/index.js
CHANGED
|
@@ -16,6 +16,7 @@ const providerTiers = {
|
|
|
16
16
|
'codepen',
|
|
17
17
|
'cults3d',
|
|
18
18
|
'cursor',
|
|
19
|
+
'dailymotion',
|
|
19
20
|
'deezer',
|
|
20
21
|
'deviantart',
|
|
21
22
|
'discord',
|
|
@@ -31,11 +32,13 @@ const providerTiers = {
|
|
|
31
32
|
'hevy',
|
|
32
33
|
'instagram',
|
|
33
34
|
'juejin',
|
|
35
|
+
'keybase',
|
|
34
36
|
'kick',
|
|
35
37
|
'ko-fi',
|
|
36
38
|
'linkedin',
|
|
37
39
|
'mastodon',
|
|
38
40
|
'medium',
|
|
41
|
+
'minecraft',
|
|
39
42
|
'netease-music',
|
|
40
43
|
'npm',
|
|
41
44
|
'onlyfans',
|
|
@@ -105,6 +108,7 @@ module.exports = ctx => {
|
|
|
105
108
|
codepen: require('./codepen')(ctx),
|
|
106
109
|
cults3d: require('./cults3d')(ctx),
|
|
107
110
|
cursor: require('./cursor')(ctx),
|
|
111
|
+
dailymotion: require('./dailymotion')(ctx),
|
|
108
112
|
deezer: require('./deezer')(ctx),
|
|
109
113
|
deviantart: require('./deviantart')(ctx),
|
|
110
114
|
discord: require('./discord')(ctx),
|
|
@@ -123,12 +127,14 @@ module.exports = ctx => {
|
|
|
123
127
|
hevy: require('./hevy')(ctx),
|
|
124
128
|
instagram: require('./instagram')(ctx),
|
|
125
129
|
juejin: require('./juejin')(ctx),
|
|
130
|
+
keybase: require('./keybase')(ctx),
|
|
126
131
|
kick: require('./kick')(ctx),
|
|
127
132
|
'ko-fi': require('./ko-fi')(ctx),
|
|
128
133
|
linkedin: require('./linkedin')(ctx),
|
|
129
134
|
mastodon: require('./mastodon')(ctx),
|
|
130
135
|
medium: require('./medium')(ctx),
|
|
131
136
|
microlink: require('./microlink')(ctx),
|
|
137
|
+
minecraft: require('./minecraft')(ctx),
|
|
132
138
|
'netease-music': require('./netease-music')(ctx),
|
|
133
139
|
npm: require('./npm')(ctx),
|
|
134
140
|
onlyfans: require('./onlyfans')(ctx),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const stringify = require('../util/stringify')
|
|
4
|
+
|
|
5
|
+
const API_URL = 'https://keybase.io/_/api/1.0/user/lookup.json'
|
|
6
|
+
|
|
7
|
+
const getAvatarUrl = input =>
|
|
8
|
+
`${API_URL}?${stringify({ username: input, fields: 'pictures' })}`
|
|
9
|
+
|
|
10
|
+
const getAvatar = body => body?.them?.pictures?.primary?.url || undefined
|
|
11
|
+
|
|
12
|
+
module.exports = ({ got }) =>
|
|
13
|
+
async function keybase (input) {
|
|
14
|
+
const { body, statusCode } = await got(getAvatarUrl(input), {
|
|
15
|
+
responseType: 'json',
|
|
16
|
+
throwHttpErrors: false
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
if (statusCode >= 400) return
|
|
20
|
+
|
|
21
|
+
return getAvatar(body)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
25
|
+
module.exports.getAvatar = getAvatar
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const MOJANG_PROFILE_API_URL =
|
|
4
|
+
'https://api.minecraftservices.com/minecraft/profile/lookup'
|
|
5
|
+
const MC_HEADS_AVATAR_URL = 'https://mc-heads.net/avatar'
|
|
6
|
+
|
|
7
|
+
const UUID_RE =
|
|
8
|
+
/^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i
|
|
9
|
+
|
|
10
|
+
const parseInput = input =>
|
|
11
|
+
UUID_RE.test(input)
|
|
12
|
+
? { type: 'uuid', value: input.replace(/-/g, '').toLowerCase() }
|
|
13
|
+
: { type: 'name', value: input }
|
|
14
|
+
|
|
15
|
+
const getAvatarUrl = input => {
|
|
16
|
+
const { type, value } = parseInput(input)
|
|
17
|
+
const path = type === 'uuid' ? value : `name/${encodeURIComponent(value)}`
|
|
18
|
+
return `${MOJANG_PROFILE_API_URL}/${path}`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const getAvatar = (body, size) =>
|
|
22
|
+
typeof body?.id === 'string' && body.id
|
|
23
|
+
? `${MC_HEADS_AVATAR_URL}/${body.id}/${size}`
|
|
24
|
+
: undefined
|
|
25
|
+
|
|
26
|
+
module.exports = ({ constants, got }) =>
|
|
27
|
+
async function minecraft (input) {
|
|
28
|
+
const { statusCode, body } = await got(getAvatarUrl(input), {
|
|
29
|
+
responseType: 'json',
|
|
30
|
+
throwHttpErrors: false
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
if (statusCode >= 400) return
|
|
34
|
+
|
|
35
|
+
return getAvatar(body, constants.AVATAR_SIZE)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports.parseInput = parseInput
|
|
39
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
40
|
+
module.exports.getAvatar = getAvatar
|