@unavatar/core 3.58.0 → 3.60.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 CHANGED
@@ -24,6 +24,7 @@
24
24
  - [Behance](#behance)
25
25
  - [Bilibili](#bilibili)
26
26
  - [BIMI](#bimi)
27
+ - [Bitbucket](#bitbucket)
27
28
  - [Bluesky](#bluesky)
28
29
  - [Buy Me a Coffee](#buy-me-a-coffee)
29
30
  - [Cash App](#cash-app)
@@ -54,6 +55,7 @@
54
55
  - [Hugging Face](#hugging-face)
55
56
  - [Instagram](#instagram)
56
57
  - [Juejin](#juejin)
58
+ - [Kaggle](#kaggle)
57
59
  - [Keybase](#keybase)
58
60
  - [Kick](#kick)
59
61
  - [Ko-fi](#ko-fi)
@@ -66,6 +68,7 @@
66
68
  - [NetEase Music](#netease-music)
67
69
  - [npm](#npm)
68
70
  - [OnlyFans](#onlyfans)
71
+ - [Open Collective](#open-collective)
69
72
  - [OpenStreetMap](#openstreetmap)
70
73
  - [osu!](#osu)
71
74
  - [Patreon](#patreon)
@@ -609,6 +612,12 @@ Available inputs:
609
612
  - Domain, e.g., [unavatar.io/bimi/cnn.com](https://unavatar.io/bimi/cnn.com)
610
613
  - Email address, e.g., [unavatar.io/bimi/support@ebay.com](https://unavatar.io/bimi/support@ebay.com)
611
614
 
615
+ ### Bitbucket
616
+
617
+ Get any Bitbucket workspace's avatar by its workspace slug. Personal accounts are covered through their personal workspace, which shares the account's username.
618
+
619
+ e.g., [unavatar.io/bitbucket/atlassian](https://unavatar.io/bitbucket/atlassian)
620
+
612
621
  ### Bluesky
613
622
 
614
623
  Get any Bluesky user's profile picture by their handle. Domain-style handles are supported.
@@ -856,6 +865,12 @@ Get any Juejin user's profile picture by their numeric user ID.
856
865
 
857
866
  e.g., [unavatar.io/juejin/1556564194374926](https://unavatar.io/juejin/1556564194374926)
858
867
 
868
+ ### Kaggle
869
+
870
+ Get any Kaggle user's profile picture by their username.
871
+
872
+ e.g., [unavatar.io/kaggle/jhoward](https://unavatar.io/kaggle/jhoward)
873
+
859
874
  ### Keybase
860
875
 
861
876
  Get any Keybase user's profile picture by their username.
@@ -936,6 +951,12 @@ Get any OnlyFans creator's profile picture by their username.
936
951
 
937
952
  e.g., [unavatar.io/onlyfans/amandaribas](https://unavatar.io/onlyfans/amandaribas)
938
953
 
954
+ ### Open Collective
955
+
956
+ Get any Open Collective account's avatar by its profile slug, for collectives, organizations, and individuals.
957
+
958
+ e.g., [unavatar.io/opencollective/webpack](https://unavatar.io/opencollective/webpack)
959
+
939
960
  ### OpenStreetMap
940
961
 
941
962
  Get any OpenStreetMap contributor's profile picture. Accepts either a numeric user ID or a username.
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.58.0",
5
+ "version": "3.60.0",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
@@ -0,0 +1,27 @@
1
+ 'use strict'
2
+
3
+ const WORKSPACES_URL = 'https://bitbucket.org/workspaces'
4
+ const DEFAULT_AVATAR_PATH = '/default_workspace_avatar/'
5
+
6
+ const getAvatarUrl = input =>
7
+ `${WORKSPACES_URL}/${encodeURIComponent(input)}/avatar/`
8
+
9
+ const getAvatar = location => {
10
+ if (!location) return
11
+ const url = new URL(location, WORKSPACES_URL)
12
+ return url.pathname.includes(DEFAULT_AVATAR_PATH) ? undefined : url.toString()
13
+ }
14
+
15
+ module.exports = ({ got }) =>
16
+ async function bitbucket (input) {
17
+ const { headers } = await got(getAvatarUrl(input), {
18
+ method: 'HEAD',
19
+ followRedirect: false,
20
+ throwHttpErrors: false
21
+ })
22
+
23
+ return getAvatar(headers.location)
24
+ }
25
+
26
+ module.exports.getAvatarUrl = getAvatarUrl
27
+ module.exports.getAvatar = getAvatar
@@ -9,6 +9,7 @@ const providerTiers = {
9
9
  'apple-store',
10
10
  'behance',
11
11
  'bilibili',
12
+ 'bitbucket',
12
13
  'bluesky',
13
14
  'buymeacoffee',
14
15
  'cashapp',
@@ -34,6 +35,7 @@ const providerTiers = {
34
35
  'hevy',
35
36
  'instagram',
36
37
  'juejin',
38
+ 'kaggle',
37
39
  'keybase',
38
40
  'kick',
39
41
  'ko-fi',
@@ -45,6 +47,7 @@ const providerTiers = {
45
47
  'netease-music',
46
48
  'npm',
47
49
  'onlyfans',
50
+ 'opencollective',
48
51
  'openstreetmap',
49
52
  'osu',
50
53
  'patreon',
@@ -105,6 +108,7 @@ module.exports = ctx => {
105
108
  behance: require('./behance')(ctx),
106
109
  bilibili: require('./bilibili')(ctx),
107
110
  bimi: require('./bimi')(ctx),
111
+ bitbucket: require('./bitbucket')(ctx),
108
112
  bluesky: require('./bluesky')(ctx),
109
113
  buymeacoffee: require('./buymeacoffee')(ctx),
110
114
  cashapp: require('./cashapp')(ctx),
@@ -133,6 +137,7 @@ module.exports = ctx => {
133
137
  hevy: require('./hevy')(ctx),
134
138
  instagram: require('./instagram')(ctx),
135
139
  juejin: require('./juejin')(ctx),
140
+ kaggle: require('./kaggle')(ctx),
136
141
  keybase: require('./keybase')(ctx),
137
142
  kick: require('./kick')(ctx),
138
143
  'ko-fi': require('./ko-fi')(ctx),
@@ -145,6 +150,7 @@ module.exports = ctx => {
145
150
  'netease-music': require('./netease-music')(ctx),
146
151
  npm: require('./npm')(ctx),
147
152
  onlyfans: require('./onlyfans')(ctx),
153
+ opencollective: require('./opencollective')(ctx),
148
154
  openstreetmap: require('./openstreetmap')(ctx),
149
155
  osu: require('./osu')(ctx),
150
156
  patreon: require('./patreon')(ctx),
@@ -0,0 +1,38 @@
1
+ 'use strict'
2
+
3
+ const THUMBNAIL_URL_PREFIX =
4
+ 'https://storage.googleapis.com/kaggle-avatars/thumbnails/'
5
+ const FULL_SIZE_URL_PREFIX =
6
+ 'https://storage.googleapis.com/kaggle-avatars/images/'
7
+ const DEFAULT_AVATAR_FILENAME = 'default-thumb.png'
8
+ const UNCHALLENGED_CRAWLER_USER_AGENT =
9
+ 'Googlebot/2.1 (+http://www.google.com/bot.html)'
10
+
11
+ const getAvatarUrl = input => `https://www.kaggle.com/${input}`
12
+
13
+ const getAvatar = ({ $, NOT_FOUND }) => {
14
+ const src =
15
+ $('meta[name="twitter:image"]').attr('content') ||
16
+ $('meta[property="twitter:image"]').attr('content')
17
+ if (!src) return
18
+
19
+ if (!src.startsWith(THUMBNAIL_URL_PREFIX)) return NOT_FOUND
20
+
21
+ const filename = src.slice(THUMBNAIL_URL_PREFIX.length)
22
+ if (filename === DEFAULT_AVATAR_FILENAME) return NOT_FOUND
23
+
24
+ return FULL_SIZE_URL_PREFIX + filename
25
+ }
26
+
27
+ module.exports = ({ createHtmlProvider, NOT_FOUND }) =>
28
+ createHtmlProvider({
29
+ name: 'kaggle',
30
+ url: getAvatarUrl,
31
+ getter: $ => getAvatar({ $, NOT_FOUND }),
32
+ htmlOpts: () => ({
33
+ headers: { 'user-agent': UNCHALLENGED_CRAWLER_USER_AGENT }
34
+ })
35
+ })
36
+
37
+ module.exports.getAvatarUrl = getAvatarUrl
38
+ module.exports.getAvatar = getAvatar
@@ -0,0 +1,27 @@
1
+ 'use strict'
2
+
3
+ const PROFILE_URL = 'https://opencollective.com'
4
+ const IMAGES_URL = 'https://images.opencollective.com'
5
+
6
+ const getProfileUrl = input =>
7
+ `${PROFILE_URL}/${encodeURIComponent(input)}.json`
8
+
9
+ const getAvatarUrl = ({ constants, slug }) =>
10
+ `${IMAGES_URL}/${encodeURIComponent(slug)}/avatar/${
11
+ constants.AVATAR_SIZE
12
+ }.png`
13
+
14
+ module.exports = ({ constants, got }) =>
15
+ async function opencollective (input) {
16
+ const { body, statusCode } = await got(getProfileUrl(input), {
17
+ responseType: 'json',
18
+ throwHttpErrors: false
19
+ })
20
+
21
+ if (statusCode >= 400 || !body?.image || !body.slug) return
22
+
23
+ return getAvatarUrl({ constants, slug: body.slug })
24
+ }
25
+
26
+ module.exports.getProfileUrl = getProfileUrl
27
+ module.exports.getAvatarUrl = getAvatarUrl