@unavatar/core 3.9.29 → 3.9.30
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.9.
|
|
5
|
+
"version": "3.9.30",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
@@ -5,5 +5,5 @@ module.exports = ({ createHtmlProvider, getOgImage }) =>
|
|
|
5
5
|
name: 'instagram',
|
|
6
6
|
url: input => `https://www.instagram.com/${input}`,
|
|
7
7
|
getter: getOgImage,
|
|
8
|
-
isBlocked: $ => $('title').text() === 'Login \u2022 Instagram'
|
|
8
|
+
isBlocked: ({ $ }) => $('title').text() === 'Login \u2022 Instagram'
|
|
9
9
|
})
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const LINKEDIN_BLOCKED_STATUS = 999
|
|
4
|
+
|
|
3
5
|
const getAvatarUrl = input => {
|
|
4
6
|
const [first, second] = input.split(':')
|
|
5
7
|
const type = second ? first : 'user'
|
|
@@ -12,7 +14,8 @@ module.exports = ({ createHtmlProvider, getOgImage }) =>
|
|
|
12
14
|
createHtmlProvider({
|
|
13
15
|
name: 'linkedin',
|
|
14
16
|
url: getAvatarUrl,
|
|
15
|
-
getter: getOgImage
|
|
17
|
+
getter: getOgImage,
|
|
18
|
+
isBlocked: ({ statusCode }) => statusCode === LINKEDIN_BLOCKED_STATUS
|
|
16
19
|
})
|
|
17
20
|
|
|
18
21
|
module.exports.getAvatarUrl = getAvatarUrl
|
|
@@ -40,7 +40,7 @@ module.exports = ({ PROXY_TIMEOUT, getHTML, onFetchHTML }) => {
|
|
|
40
40
|
* Extracts the avatar URL from the fetched HTML.
|
|
41
41
|
* - `string` — avatar URL found (success).
|
|
42
42
|
* - `undefined` — avatar not found (normal failure, no retry).
|
|
43
|
-
* @param {($: cheerio.CheerioAPI) => boolean} [opts.isBlocked]
|
|
43
|
+
* @param {(context: { $: cheerio.CheerioAPI, statusCode: number }) => boolean} [opts.isBlocked]
|
|
44
44
|
* Optional provider-specific blocked-page detector, checked after the
|
|
45
45
|
* default `is-antibot` check when getter returns empty/undefined.
|
|
46
46
|
* @param {() => object} [opts.htmlOpts] - Returns extra options merged into the fetch call.
|
|
@@ -111,7 +111,7 @@ module.exports = ({ PROXY_TIMEOUT, getHTML, onFetchHTML }) => {
|
|
|
111
111
|
})
|
|
112
112
|
|
|
113
113
|
const isRateLimited = statusCode === httpStatus.TOO_MANY_REQUESTS
|
|
114
|
-
const providerBlocked = isBlocked?.(
|
|
114
|
+
const providerBlocked = isBlocked?.({ $, statusCode })
|
|
115
115
|
|
|
116
116
|
const { detected: antibotDetected, provider: antibotProvider } =
|
|
117
117
|
isRateLimited || providerBlocked
|