@unavatar/core 3.31.0 → 3.31.1
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/buymeacoffee.js +3 -3
- package/src/providers/dockerhub.js +3 -3
- package/src/providers/flickr.js +7 -5
- package/src/providers/github.js +27 -24
- package/src/providers/ko-fi.js +3 -3
- package/src/providers/mastodon.js +3 -3
- package/src/providers/onlyfans.js +3 -3
- package/src/providers/pinterest.js +5 -4
- package/src/providers/psnprofiles.js +3 -3
- package/src/providers/stackoverflow.js +5 -5
- package/src/providers/substack.js +3 -4
- package/src/providers/thingiverse.js +6 -6
- package/src/providers/tiktok.js +3 -3
- package/src/providers/x.js +3 -3
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.31.
|
|
5
|
+
"version": "3.31.1",
|
|
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 getAvatar = $ => {
|
|
4
4
|
const dataPage = $('#app').attr('data-page')
|
|
5
5
|
if (!dataPage) return
|
|
6
6
|
|
|
@@ -16,9 +16,9 @@ const factory = ({ createHtmlProvider }) =>
|
|
|
16
16
|
createHtmlProvider({
|
|
17
17
|
name: 'buymeacoffee',
|
|
18
18
|
url: input => `https://buymeacoffee.com/${input}`,
|
|
19
|
-
getter:
|
|
19
|
+
getter: getAvatar
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
factory.
|
|
22
|
+
factory.getAvatar = getAvatar
|
|
23
23
|
|
|
24
24
|
module.exports = factory
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const API_URL = 'https://hub.docker.com/v2/users'
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const getAvatarUrl = input => `${API_URL}/${encodeURIComponent(input)}/`
|
|
6
6
|
|
|
7
7
|
module.exports = ({ got }) =>
|
|
8
8
|
async function dockerhub (input) {
|
|
9
|
-
const { body, statusCode } = await got(
|
|
9
|
+
const { body, statusCode } = await got(getAvatarUrl(input), {
|
|
10
10
|
responseType: 'json',
|
|
11
11
|
throwHttpErrors: false
|
|
12
12
|
})
|
|
@@ -16,4 +16,4 @@ module.exports = ({ got }) =>
|
|
|
16
16
|
return body?.gravatar_url || undefined
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
module.exports.
|
|
19
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
package/src/providers/flickr.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const BUDDY_ICON_URL_PATTERN =
|
|
3
|
+
const BUDDY_ICON_URL_PATTERN =
|
|
4
|
+
/(?:https?:)?\/\/[^"'()\s]*\/buddyicons\/[^"'()\s]+/i
|
|
4
5
|
const CSS_URL_PATTERN = /url\((['"]?)([^)'"]+)\1\)/i
|
|
5
6
|
const unescapePathSlashes = value => value?.replace(/\\\//g, '/')
|
|
6
7
|
|
|
@@ -19,7 +20,8 @@ const getBuddyIconFromText = value => {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const getUserProfileUrl = userId => `https://www.flickr.com/photos/${userId}/`
|
|
22
|
-
const getGroupProfileUrl = groupId =>
|
|
23
|
+
const getGroupProfileUrl = groupId =>
|
|
24
|
+
`https://www.flickr.com/groups/${groupId}/`
|
|
23
25
|
|
|
24
26
|
const getAvatarUrl = input => {
|
|
25
27
|
const { type, id } = parseInput(input)
|
|
@@ -41,7 +43,7 @@ const getBuddyIconFromCss = value => {
|
|
|
41
43
|
return getBuddyIconFromText(cssUrl)
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
const
|
|
46
|
+
const getAvatar = $ => {
|
|
45
47
|
const imgBuddyIcon = $('img[src*="/buddyicons/"]').first().attr('src')
|
|
46
48
|
if (imgBuddyIcon) return imgBuddyIcon
|
|
47
49
|
|
|
@@ -57,8 +59,8 @@ module.exports = ({ createHtmlProvider }) =>
|
|
|
57
59
|
createHtmlProvider({
|
|
58
60
|
name: 'flickr',
|
|
59
61
|
url: getAvatarUrl,
|
|
60
|
-
getter:
|
|
62
|
+
getter: getAvatar
|
|
61
63
|
})
|
|
62
64
|
|
|
63
65
|
module.exports.getAvatarUrl = getAvatarUrl
|
|
64
|
-
module.exports.
|
|
66
|
+
module.exports.getAvatar = getAvatar
|
package/src/providers/github.js
CHANGED
|
@@ -12,8 +12,9 @@ const COMMIT_SEARCH_ACCEPT_HEADER = 'application/vnd.github+json'
|
|
|
12
12
|
const normalizeValue = value =>
|
|
13
13
|
typeof value === 'string' ? value.trim().toLowerCase() : ''
|
|
14
14
|
const getSearchItems = body => body?.items ?? []
|
|
15
|
-
const getUniqueLogins = candidates =>
|
|
16
|
-
|
|
15
|
+
const getUniqueLogins = candidates => [
|
|
16
|
+
...new Set(candidates.map(({ login }) => login).filter(Boolean))
|
|
17
|
+
]
|
|
17
18
|
|
|
18
19
|
const fetchJsonBody = async ({ got, url, options }) => {
|
|
19
20
|
const { body } = await got(url, {
|
|
@@ -38,21 +39,22 @@ const pickLinkedUser = item => {
|
|
|
38
39
|
if (isResolvablePerson(item.committer)) return item.committer
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
+
const getAvatarUrl = ({ constants, input }) =>
|
|
42
43
|
`https://github.com/${input}.png?${stringify({
|
|
43
44
|
size: constants.AVATAR_SIZE
|
|
44
45
|
})}`
|
|
45
46
|
|
|
46
|
-
const createSearchUsersByEmail =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
const createSearchUsersByEmail =
|
|
48
|
+
({ got }) =>
|
|
49
|
+
async email => {
|
|
50
|
+
const body = await fetchJsonBody({
|
|
51
|
+
got,
|
|
52
|
+
url: `${GITHUB_API_URL}/search/users?q=${encodeURIComponent(
|
|
51
53
|
email
|
|
52
54
|
)}&per_page=${SEARCH_USERS_PER_PAGE}`
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
})
|
|
56
|
+
return getSearchItems(body)
|
|
57
|
+
}
|
|
56
58
|
|
|
57
59
|
const createGetUser = ({ githubSearchCache, got }) =>
|
|
58
60
|
memoize(
|
|
@@ -65,20 +67,21 @@ const createGetUser = ({ githubSearchCache, got }) =>
|
|
|
65
67
|
{ key: login => `user:${normalizeValue(login)}` }
|
|
66
68
|
)
|
|
67
69
|
|
|
68
|
-
const createSearchCommitsByEmail =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
const createSearchCommitsByEmail =
|
|
71
|
+
({ got }) =>
|
|
72
|
+
async email => {
|
|
73
|
+
const body = await fetchJsonBody({
|
|
74
|
+
got,
|
|
75
|
+
url: `${GITHUB_API_URL}/search/commits?q=${encodeURIComponent(
|
|
73
76
|
`author-email:${email}`
|
|
74
77
|
)}&per_page=${SEARCH_COMMITS_PER_PAGE}`,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
options: {
|
|
79
|
+
headers: { accept: COMMIT_SEARCH_ACCEPT_HEADER }
|
|
80
|
+
}
|
|
81
|
+
})
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
return getSearchItems(body)
|
|
84
|
+
}
|
|
82
85
|
|
|
83
86
|
const findExactPublicProfileMatches = async ({
|
|
84
87
|
email,
|
|
@@ -156,7 +159,7 @@ module.exports = ({ constants, githubSearchCache, got }) => {
|
|
|
156
159
|
const searchCommitsByEmail = createSearchCommitsByEmail({ got })
|
|
157
160
|
|
|
158
161
|
return async function github (input) {
|
|
159
|
-
if (!isEmail(input)) return
|
|
162
|
+
if (!isEmail(input)) return getAvatarUrl({ constants, input })
|
|
160
163
|
const email = normalizeValue(input)
|
|
161
164
|
|
|
162
165
|
// Strategy: exact public user email -> user commit consensus ->
|
|
@@ -180,6 +183,6 @@ module.exports = ({ constants, githubSearchCache, got }) => {
|
|
|
180
183
|
}
|
|
181
184
|
}
|
|
182
185
|
|
|
183
|
-
module.exports.
|
|
186
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
184
187
|
module.exports.findExactPublicProfileMatches = findExactPublicProfileMatches
|
|
185
188
|
module.exports.findCommitConsensusMatch = findCommitConsensusMatch
|
package/src/providers/ko-fi.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const getAvatar = $ => $('img#profilePicture').attr('src')
|
|
4
4
|
|
|
5
5
|
const factory = ({ createHtmlProvider }) =>
|
|
6
6
|
createHtmlProvider({
|
|
7
7
|
name: 'ko-fi',
|
|
8
8
|
url: input => `https://ko-fi.com/${input}`,
|
|
9
|
-
getter:
|
|
9
|
+
getter: getAvatar
|
|
10
10
|
})
|
|
11
11
|
|
|
12
|
-
factory.
|
|
12
|
+
factory.getAvatar = getAvatar
|
|
13
13
|
|
|
14
14
|
module.exports = factory
|
|
@@ -17,7 +17,7 @@ const isValidServer = server => {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const parseInput = input => {
|
|
21
21
|
if (typeof input !== 'string') return
|
|
22
22
|
|
|
23
23
|
const cleaned = input.startsWith('@') ? input.slice(1) : input
|
|
@@ -36,7 +36,7 @@ const parseMastodonInput = input => {
|
|
|
36
36
|
|
|
37
37
|
module.exports = ({ got, isReservedIp }) => {
|
|
38
38
|
const mastodon = async function (input) {
|
|
39
|
-
const parsed =
|
|
39
|
+
const parsed = parseInput(input)
|
|
40
40
|
if (!parsed) return
|
|
41
41
|
|
|
42
42
|
const { username, server } = parsed
|
|
@@ -56,4 +56,4 @@ module.exports = ({ got, isReservedIp }) => {
|
|
|
56
56
|
return mastodon
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
module.exports.
|
|
59
|
+
module.exports.parseInput = parseInput
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { get } = require('lodash')
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const getAvatar = $ => {
|
|
6
6
|
const text = $('script[type="application/ld+json"]').contents().text()
|
|
7
7
|
return text ? get(JSON.parse(text), 'mainEntity.image') : undefined
|
|
8
8
|
}
|
|
@@ -11,7 +11,7 @@ module.exports = ({ createHtmlProvider }) =>
|
|
|
11
11
|
createHtmlProvider({
|
|
12
12
|
name: 'onlyfans',
|
|
13
13
|
url: input => `https://onlyfans.com/${input}`,
|
|
14
|
-
getter:
|
|
14
|
+
getter: getAvatar,
|
|
15
15
|
htmlOpts: () => ({
|
|
16
16
|
prerender: true,
|
|
17
17
|
puppeteerOpts: {
|
|
@@ -21,4 +21,4 @@ module.exports = ({ createHtmlProvider }) =>
|
|
|
21
21
|
})
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
module.exports.
|
|
24
|
+
module.exports.getAvatar = getAvatar
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
const { $jsonld } = require('@metascraper/helpers')
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const getAvatarUrl = input => `https://www.pinterest.com/${input}/`
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const getAvatar = $jsonld('mainEntity.image.contentUrl')
|
|
8
8
|
|
|
9
9
|
module.exports = ({ createHtmlProvider }) =>
|
|
10
10
|
createHtmlProvider({
|
|
11
11
|
name: 'pinterest',
|
|
12
|
-
url:
|
|
13
|
-
getter:
|
|
12
|
+
url: getAvatarUrl,
|
|
13
|
+
getter: getAvatar
|
|
14
14
|
})
|
|
15
15
|
|
|
16
16
|
module.exports.getAvatarUrl = getAvatarUrl
|
|
17
|
+
module.exports.getAvatar = getAvatar
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const getAvatar = ({ $, getOgImage, NOT_FOUND }) => {
|
|
4
4
|
const ogImage = getOgImage($)
|
|
5
5
|
return ogImage === undefined ? NOT_FOUND : ogImage
|
|
6
6
|
}
|
|
@@ -9,7 +9,7 @@ module.exports = ({ createHtmlProvider, getOgImage, NOT_FOUND }) =>
|
|
|
9
9
|
createHtmlProvider({
|
|
10
10
|
name: 'psnprofiles',
|
|
11
11
|
url: input => `https://psnprofiles.com/${input}`,
|
|
12
|
-
getter: $ =>
|
|
12
|
+
getter: $ => getAvatar({ $, getOgImage, NOT_FOUND })
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
module.exports.
|
|
15
|
+
module.exports.getAvatar = getAvatar
|
|
@@ -8,19 +8,19 @@ const normalizeUserId = input =>
|
|
|
8
8
|
.replace(/^users\//, '')
|
|
9
9
|
.split('/')[0]
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const getAvatarUrl = input =>
|
|
12
12
|
`https://stackoverflow.com/users/${normalizeUserId(input)}`
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const getAvatar = $ =>
|
|
15
15
|
$(`${AVATAR_SELECTOR}[width="128"]`).attr('src') ||
|
|
16
16
|
$(AVATAR_SELECTOR).first().attr('src')
|
|
17
17
|
|
|
18
18
|
module.exports = ({ createHtmlProvider }) =>
|
|
19
19
|
createHtmlProvider({
|
|
20
20
|
name: 'stackoverflow',
|
|
21
|
-
url:
|
|
22
|
-
getter:
|
|
21
|
+
url: getAvatarUrl,
|
|
22
|
+
getter: getAvatar
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
module.exports.getProfileUrl = getProfileUrl
|
|
26
25
|
module.exports.getAvatarUrl = getAvatarUrl
|
|
26
|
+
module.exports.getAvatar = getAvatar
|
|
@@ -23,14 +23,13 @@ const getPictureAvatar = $ => {
|
|
|
23
23
|
return getBestSrcsetUrl(srcset) || pictureImg.attr('src')
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const
|
|
27
|
-
$jsonld('publisher.logo.url')($) || getPictureAvatar($)
|
|
26
|
+
const getAvatar = $ => $jsonld('publisher.logo.url')($) || getPictureAvatar($)
|
|
28
27
|
|
|
29
28
|
module.exports = ({ createHtmlProvider }) =>
|
|
30
29
|
createHtmlProvider({
|
|
31
30
|
name: 'substack',
|
|
32
31
|
url: input => `https://${input}.substack.com`,
|
|
33
|
-
getter:
|
|
32
|
+
getter: getAvatar
|
|
34
33
|
})
|
|
35
34
|
|
|
36
|
-
module.exports.
|
|
35
|
+
module.exports.getAvatar = getAvatar
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const getAvatarUrl = input => `https://www.thingiverse.com/${input}`
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const getAvatar = ({ getOgImage, $ }) =>
|
|
6
6
|
new URL(getOgImage($)).searchParams.get('url')
|
|
7
7
|
|
|
8
8
|
module.exports = ({ createHtmlProvider, getOgImage }) =>
|
|
9
9
|
createHtmlProvider({
|
|
10
10
|
name: 'thingiverse',
|
|
11
|
-
url:
|
|
12
|
-
getter: $ =>
|
|
11
|
+
url: getAvatarUrl,
|
|
12
|
+
getter: $ => getAvatar({ getOgImage, $ })
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
module.exports.getAvatarUrl =
|
|
16
|
-
module.exports.
|
|
15
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
16
|
+
module.exports.getAvatar = getAvatar
|
package/src/providers/tiktok.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { get } = require('lodash')
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const getAvatar = $ => {
|
|
6
6
|
const text = $('#__UNIVERSAL_DATA_FOR_REHYDRATION__').contents().text()
|
|
7
7
|
if (!text) return
|
|
8
8
|
return get(JSON.parse(text), [
|
|
@@ -18,7 +18,7 @@ module.exports = ({ createHtmlProvider }) =>
|
|
|
18
18
|
createHtmlProvider({
|
|
19
19
|
name: 'tiktok',
|
|
20
20
|
url: input => `https://www.tiktok.com/@${input}`,
|
|
21
|
-
getter:
|
|
21
|
+
getter: getAvatar
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
module.exports.
|
|
24
|
+
module.exports.getAvatar = getAvatar
|
package/src/providers/x.js
CHANGED
|
@@ -12,14 +12,14 @@ const toHighResolution = url => {
|
|
|
12
12
|
return url
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const getAvatar = ($, getOgImage) =>
|
|
16
16
|
toHighResolution($jsonld('mainEntity.image.contentUrl')($) || getOgImage($))
|
|
17
17
|
|
|
18
18
|
module.exports = ({ createHtmlProvider, getOgImage }) =>
|
|
19
19
|
createHtmlProvider({
|
|
20
20
|
name: 'x',
|
|
21
21
|
url: input => `https://x.com/${input}`,
|
|
22
|
-
getter: $ =>
|
|
22
|
+
getter: $ => getAvatar($, getOgImage)
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
module.exports.
|
|
25
|
+
module.exports.getAvatar = getAvatar
|