@unavatar/core 3.7.77 → 3.7.78
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 +1 -1
- package/src/providers/linkedin.js +4 -2
- package/src/providers/mastodon.js +2 -1
- package/src/providers/onlyfans.js +3 -2
- package/src/providers/openstreetmap.js +12 -8
- package/src/providers/patreon.js +2 -4
- package/src/providers/printables.js +6 -4
- package/src/providers/spotify.js +5 -3
- package/src/providers/substack.js +7 -6
- package/src/providers/tiktok.js +2 -4
- package/src/providers/whatsapp.js +4 -2
- package/src/providers/x.js +2 -4
- package/src/providers/youtube.js +15 -11
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.7.
|
|
5
|
+
"version": "3.7.78",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const getAvatarUrl = input => {
|
|
4
4
|
const [first, second] = input.split(':')
|
|
5
5
|
const type = second ? first : 'user'
|
|
6
6
|
const id = second ?? first
|
|
@@ -11,6 +11,8 @@ const linkedinUrl = input => {
|
|
|
11
11
|
module.exports = ({ createHtmlProvider, getOgImage }) =>
|
|
12
12
|
createHtmlProvider({
|
|
13
13
|
name: 'linkedin',
|
|
14
|
-
url:
|
|
14
|
+
url: getAvatarUrl,
|
|
15
15
|
getter: getOgImage
|
|
16
16
|
})
|
|
17
|
+
|
|
18
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
@@ -4,8 +4,7 @@ const { get } = require('lodash')
|
|
|
4
4
|
|
|
5
5
|
const getAvatarUrl = $ => {
|
|
6
6
|
const text = $('script[type="application/ld+json"]').contents().text()
|
|
7
|
-
|
|
8
|
-
return get(JSON.parse(text), 'mainEntity.image')
|
|
7
|
+
return text ? get(JSON.parse(text), 'mainEntity.image') : undefined
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
module.exports = ({ createHtmlProvider }) =>
|
|
@@ -21,3 +20,5 @@ module.exports = ({ createHtmlProvider }) =>
|
|
|
21
20
|
}
|
|
22
21
|
})
|
|
23
22
|
})
|
|
23
|
+
|
|
24
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const OPENSTREETMAP_API_URL = 'https://api.openstreetmap.org/api/0.6/user'
|
|
4
|
+
|
|
3
5
|
const OPENSTREETMAP_USER_ID_REGEX = /^\d+$/
|
|
4
6
|
|
|
5
7
|
module.exports = ({ got, createHtmlProvider }) => {
|
|
6
|
-
const fromID = userId =>
|
|
7
|
-
got(`https://api.openstreetmap.org/api/0.6/user/${userId}.json`, {
|
|
8
|
-
responseType: 'json'
|
|
9
|
-
}).then(({ body }) => body?.user?.img?.href)
|
|
10
|
-
|
|
11
8
|
const fromUsername = createHtmlProvider({
|
|
12
9
|
name: 'openstreetmap',
|
|
13
|
-
url: username =>
|
|
10
|
+
url: username =>
|
|
11
|
+
`https://www.openstreetmap.org/user/${encodeURIComponent(username)}`,
|
|
14
12
|
getter: $ => $('img.user_image').attr('src')
|
|
15
13
|
})
|
|
16
14
|
|
|
17
|
-
return function openstreetmap (
|
|
18
|
-
return OPENSTREETMAP_USER_ID_REGEX.test(input)
|
|
15
|
+
return function openstreetmap (ctx) {
|
|
16
|
+
return OPENSTREETMAP_USER_ID_REGEX.test(ctx.input)
|
|
17
|
+
? got(`${OPENSTREETMAP_API_URL}/${ctx.input}.json`, {
|
|
18
|
+
responseType: 'json'
|
|
19
|
+
}).then(({ body }) => body?.user?.img?.href)
|
|
20
|
+
: fromUsername(ctx)
|
|
19
21
|
}
|
|
20
22
|
}
|
|
23
|
+
|
|
24
|
+
module.exports.OPENSTREETMAP_USER_ID_REGEX = OPENSTREETMAP_USER_ID_REGEX
|
package/src/providers/patreon.js
CHANGED
|
@@ -26,13 +26,11 @@ const getRscAvatar = $ => {
|
|
|
26
26
|
const getAvatar = $ =>
|
|
27
27
|
$jsonld('mainEntity.image.contentUrl')($) || getRscAvatar($)
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
module.exports = ({ createHtmlProvider }) =>
|
|
30
30
|
createHtmlProvider({
|
|
31
31
|
name: 'patreon',
|
|
32
32
|
url: username => `https://www.patreon.com/${username}`,
|
|
33
33
|
getter: getAvatar
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
module.exports = factory
|
|
36
|
+
module.exports.getAvatar = getAvatar
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const getAvatarUrl = input =>
|
|
4
|
+
`https://www.printables.com/${input.startsWith('@') ? input : `@${input}`}`
|
|
5
|
+
|
|
3
6
|
module.exports = ({ createHtmlProvider, getOgImage }) =>
|
|
4
7
|
createHtmlProvider({
|
|
5
8
|
name: 'printables',
|
|
6
|
-
url:
|
|
7
|
-
`https://www.printables.com/${
|
|
8
|
-
input.startsWith('@') ? input : `@${input}`
|
|
9
|
-
}`,
|
|
9
|
+
url: getAvatarUrl,
|
|
10
10
|
getter: getOgImage
|
|
11
11
|
})
|
|
12
|
+
|
|
13
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
package/src/providers/spotify.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const getAvatarUrl = input => {
|
|
4
4
|
const [first, second] = input.split(':')
|
|
5
5
|
const type = second ? first : 'user'
|
|
6
6
|
const id = second ?? first
|
|
7
|
-
return
|
|
7
|
+
return `https://open.spotify.com/${type}/${id}`
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
module.exports = ({ createHtmlProvider, getOgImage }) =>
|
|
11
11
|
createHtmlProvider({
|
|
12
12
|
name: 'spotify',
|
|
13
|
-
url:
|
|
13
|
+
url: getAvatarUrl,
|
|
14
14
|
getter: getOgImage,
|
|
15
15
|
htmlOpts: () => ({
|
|
16
16
|
prerender: true
|
|
17
17
|
})
|
|
18
18
|
})
|
|
19
|
+
|
|
20
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
@@ -12,7 +12,9 @@ const getBestSrcsetUrl = srcset => {
|
|
|
12
12
|
}))
|
|
13
13
|
|
|
14
14
|
if (candidates.length === 0) return
|
|
15
|
-
return candidates.reduce((best, current) =>
|
|
15
|
+
return candidates.reduce((best, current) =>
|
|
16
|
+
current.score > best.score ? current : best
|
|
17
|
+
).url
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
const getPictureAvatar = $ => {
|
|
@@ -21,15 +23,14 @@ const getPictureAvatar = $ => {
|
|
|
21
23
|
return getBestSrcsetUrl(srcset) || pictureImg.attr('src')
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
const getAvatarUrl = $ =>
|
|
26
|
+
const getAvatarUrl = $ =>
|
|
27
|
+
$jsonld('publisher.logo.url')($) || getPictureAvatar($)
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
module.exports = ({ createHtmlProvider }) =>
|
|
27
30
|
createHtmlProvider({
|
|
28
31
|
name: 'substack',
|
|
29
32
|
url: input => `https://${input}.substack.com`,
|
|
30
33
|
getter: getAvatarUrl
|
|
31
34
|
})
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
module.exports = factory
|
|
36
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
package/src/providers/tiktok.js
CHANGED
|
@@ -14,13 +14,11 @@ const getAvatarUrl = $ => {
|
|
|
14
14
|
])
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
module.exports = ({ createHtmlProvider }) =>
|
|
18
18
|
createHtmlProvider({
|
|
19
19
|
name: 'tiktok',
|
|
20
20
|
url: input => `https://www.tiktok.com/@${input}`,
|
|
21
21
|
getter: getAvatarUrl
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
module.exports = factory
|
|
24
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
@@ -8,7 +8,7 @@ const whatsappURI = input => {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const getAvatarUrl = input => {
|
|
12
12
|
const { type, id } = whatsappURI(input)
|
|
13
13
|
switch (type) {
|
|
14
14
|
case 'phone':
|
|
@@ -26,6 +26,8 @@ const whatsappURL = input => {
|
|
|
26
26
|
module.exports = ({ createHtmlProvider, getOgImage }) =>
|
|
27
27
|
createHtmlProvider({
|
|
28
28
|
name: 'whatsapp',
|
|
29
|
-
url:
|
|
29
|
+
url: getAvatarUrl,
|
|
30
30
|
getter: getOgImage
|
|
31
31
|
})
|
|
32
|
+
|
|
33
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
package/src/providers/x.js
CHANGED
|
@@ -18,13 +18,11 @@ const getProfileImage = $ =>
|
|
|
18
18
|
$('meta[property="og:image"]').attr('content')
|
|
19
19
|
)
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
module.exports = ({ createHtmlProvider }) =>
|
|
22
22
|
createHtmlProvider({
|
|
23
23
|
name: 'x',
|
|
24
24
|
url: input => `https://x.com/${input}`,
|
|
25
25
|
getter: getProfileImage
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
module.exports = factory
|
|
28
|
+
module.exports.getProfileImage = getProfileImage
|
package/src/providers/youtube.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const getAvatarUrl = input => {
|
|
4
|
+
let path
|
|
5
|
+
if (input.startsWith('@')) {
|
|
6
|
+
path = input
|
|
7
|
+
} else if (input.startsWith('UC') && input.length === 24) {
|
|
8
|
+
path = `channel/${input}`
|
|
9
|
+
} else {
|
|
10
|
+
path = `@${input}`
|
|
11
|
+
}
|
|
12
|
+
return `https://www.youtube.com/${path}`
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
module.exports = ({ createHtmlProvider, getOgImage }) =>
|
|
4
16
|
createHtmlProvider({
|
|
5
17
|
name: 'youtube',
|
|
6
|
-
url:
|
|
7
|
-
let path
|
|
8
|
-
if (input.startsWith('@')) {
|
|
9
|
-
path = input
|
|
10
|
-
} else if (input.startsWith('UC') && input.length === 24) {
|
|
11
|
-
path = `channel/${input}`
|
|
12
|
-
} else {
|
|
13
|
-
path = `@${input}`
|
|
14
|
-
}
|
|
15
|
-
return `https://www.youtube.com/${path}`
|
|
16
|
-
},
|
|
18
|
+
url: getAvatarUrl,
|
|
17
19
|
getter: getOgImage
|
|
18
20
|
})
|
|
21
|
+
|
|
22
|
+
module.exports.getAvatarUrl = getAvatarUrl
|