@unavatar/core 3.64.0 → 3.66.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 +17 -0
- package/package.json +1 -1
- package/src/providers/farcaster.js +29 -0
- package/src/providers/index.js +4 -0
- package/src/providers/speedrun.js +32 -0
package/README.md
CHANGED
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
- [Duolingo](#duolingo)
|
|
46
46
|
- [Email](#email)
|
|
47
47
|
- [Facebook](#facebook)
|
|
48
|
+
- [Farcaster](#farcaster)
|
|
48
49
|
- [Flickr](#flickr)
|
|
49
50
|
- [Gitee](#gitee)
|
|
50
51
|
- [GitHub](#github)
|
|
@@ -89,6 +90,7 @@
|
|
|
89
90
|
- [Sketchfab](#sketchfab)
|
|
90
91
|
- [Snapchat](#snapchat)
|
|
91
92
|
- [SoundCloud](#soundcloud)
|
|
93
|
+
- [Speedrun](#speedrun)
|
|
92
94
|
- [Spotify](#spotify)
|
|
93
95
|
- [Stack Overflow](#stack-overflow)
|
|
94
96
|
- [Steam](#steam)
|
|
@@ -778,6 +780,15 @@ Available inputs:
|
|
|
778
780
|
- Username, e.g., [unavatar.io/facebook/zuck](https://unavatar.io/facebook/zuck)
|
|
779
781
|
- Page, e.g., [unavatar.io/facebook/windtodayco](https://unavatar.io/facebook/windtodayco)
|
|
780
782
|
|
|
783
|
+
### Farcaster
|
|
784
|
+
|
|
785
|
+
Get any Farcaster user's profile picture by their username (fname). ENS-style usernames are supported.
|
|
786
|
+
|
|
787
|
+
Available inputs:
|
|
788
|
+
|
|
789
|
+
- Username, e.g., [unavatar.io/farcaster/dwr](https://unavatar.io/farcaster/dwr)
|
|
790
|
+
- ENS username, e.g., [unavatar.io/farcaster/vitalik.eth](https://unavatar.io/farcaster/vitalik.eth)
|
|
791
|
+
|
|
781
792
|
### Flickr
|
|
782
793
|
|
|
783
794
|
Get any Flickr user's buddy icon or group icon by username or group slug.
|
|
@@ -1109,6 +1120,12 @@ Get any SoundCloud artist's profile picture by their username.
|
|
|
1109
1120
|
|
|
1110
1121
|
e.g., [unavatar.io/soundcloud/gorillaz](https://unavatar.io/soundcloud/gorillaz)
|
|
1111
1122
|
|
|
1123
|
+
### Speedrun
|
|
1124
|
+
|
|
1125
|
+
Get any Speedrun.com runner's profile picture by their username or user ID.
|
|
1126
|
+
|
|
1127
|
+
e.g., [unavatar.io/speedrun/cheese](https://unavatar.io/speedrun/cheese)
|
|
1128
|
+
|
|
1112
1129
|
### Spotify
|
|
1113
1130
|
|
|
1114
1131
|
Get artwork for any Spotify entity — users, artists, albums, playlists, shows, episodes, or tracks. Look up by username or Spotify 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.66.0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const API_URL = 'https://api.warpcast.com/v2/user-by-username'
|
|
4
|
+
|
|
5
|
+
const parseInput = input => input.trim().replace(/^@/, '').toLowerCase()
|
|
6
|
+
|
|
7
|
+
const getAvatarUrl = input =>
|
|
8
|
+
`${API_URL}?username=${encodeURIComponent(parseInput(input))}`
|
|
9
|
+
|
|
10
|
+
const getAvatar = body => {
|
|
11
|
+
const pic = body?.result?.user?.pfp?.url
|
|
12
|
+
return typeof pic === 'string' && pic ? pic : undefined
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = ({ got }) =>
|
|
16
|
+
async function farcaster (input) {
|
|
17
|
+
const { body, statusCode } = await got(getAvatarUrl(input), {
|
|
18
|
+
responseType: 'json',
|
|
19
|
+
throwHttpErrors: false
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
if (statusCode >= 400) return
|
|
23
|
+
|
|
24
|
+
return getAvatar(body)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports.parseInput = parseInput
|
|
28
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
29
|
+
module.exports.getAvatar = getAvatar
|
package/src/providers/index.js
CHANGED
|
@@ -27,6 +27,7 @@ const providerTiers = {
|
|
|
27
27
|
'dribbble',
|
|
28
28
|
'duolingo',
|
|
29
29
|
'facebook',
|
|
30
|
+
'farcaster',
|
|
30
31
|
'flickr',
|
|
31
32
|
'gitee',
|
|
32
33
|
'github',
|
|
@@ -67,6 +68,7 @@ const providerTiers = {
|
|
|
67
68
|
'sketchfab',
|
|
68
69
|
'snapchat',
|
|
69
70
|
'soundcloud',
|
|
71
|
+
'speedrun',
|
|
70
72
|
'spotify',
|
|
71
73
|
'stackoverflow',
|
|
72
74
|
'steam',
|
|
@@ -130,6 +132,7 @@ module.exports = ctx => {
|
|
|
130
132
|
duckduckgo: require('./duckduckgo')(ctx),
|
|
131
133
|
duolingo: require('./duolingo')(ctx),
|
|
132
134
|
facebook: require('./facebook')(ctx),
|
|
135
|
+
farcaster: require('./farcaster')(ctx),
|
|
133
136
|
flickr: require('./flickr')(ctx),
|
|
134
137
|
gitee: require('./gitee')(ctx),
|
|
135
138
|
github: require('./github')(ctx),
|
|
@@ -174,6 +177,7 @@ module.exports = ctx => {
|
|
|
174
177
|
sketchfab: require('./sketchfab')(ctx),
|
|
175
178
|
snapchat: require('./snapchat')(ctx),
|
|
176
179
|
soundcloud: require('./soundcloud')(ctx),
|
|
180
|
+
speedrun: require('./speedrun')(ctx),
|
|
177
181
|
spotify: require('./spotify')(ctx),
|
|
178
182
|
stackoverflow: require('./stackoverflow')(ctx),
|
|
179
183
|
steam: require('./steam')(ctx),
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const API_URL = 'https://www.speedrun.com/api/v1/users'
|
|
4
|
+
const FILE_EXTENSION_RE = /\.\w+$/
|
|
5
|
+
|
|
6
|
+
const getAvatarUrl = input => `${API_URL}/${encodeURIComponent(input)}`
|
|
7
|
+
|
|
8
|
+
const toStaticImageUrl = input => {
|
|
9
|
+
const url = new URL(input)
|
|
10
|
+
if (!FILE_EXTENSION_RE.test(url.pathname)) url.pathname += '.png'
|
|
11
|
+
return url.toString()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const getAvatar = body => {
|
|
15
|
+
const pic = body?.data?.assets?.image?.uri
|
|
16
|
+
return typeof pic === 'string' && pic ? toStaticImageUrl(pic) : undefined
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = ({ got }) =>
|
|
20
|
+
async function speedrun (input) {
|
|
21
|
+
const { body, statusCode } = await got(getAvatarUrl(input), {
|
|
22
|
+
responseType: 'json',
|
|
23
|
+
throwHttpErrors: false
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
if (statusCode >= 400) return
|
|
27
|
+
|
|
28
|
+
return getAvatar(body)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
|
32
|
+
module.exports.getAvatar = getAvatar
|