@unavatar/core 3.65.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 +7 -0
- package/package.json +1 -1
- package/src/providers/index.js +2 -0
- package/src/providers/speedrun.js +32 -0
package/README.md
CHANGED
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
- [Sketchfab](#sketchfab)
|
|
91
91
|
- [Snapchat](#snapchat)
|
|
92
92
|
- [SoundCloud](#soundcloud)
|
|
93
|
+
- [Speedrun](#speedrun)
|
|
93
94
|
- [Spotify](#spotify)
|
|
94
95
|
- [Stack Overflow](#stack-overflow)
|
|
95
96
|
- [Steam](#steam)
|
|
@@ -1119,6 +1120,12 @@ Get any SoundCloud artist's profile picture by their username.
|
|
|
1119
1120
|
|
|
1120
1121
|
e.g., [unavatar.io/soundcloud/gorillaz](https://unavatar.io/soundcloud/gorillaz)
|
|
1121
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
|
+
|
|
1122
1129
|
### Spotify
|
|
1123
1130
|
|
|
1124
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",
|
package/src/providers/index.js
CHANGED
|
@@ -68,6 +68,7 @@ const providerTiers = {
|
|
|
68
68
|
'sketchfab',
|
|
69
69
|
'snapchat',
|
|
70
70
|
'soundcloud',
|
|
71
|
+
'speedrun',
|
|
71
72
|
'spotify',
|
|
72
73
|
'stackoverflow',
|
|
73
74
|
'steam',
|
|
@@ -176,6 +177,7 @@ module.exports = ctx => {
|
|
|
176
177
|
sketchfab: require('./sketchfab')(ctx),
|
|
177
178
|
snapchat: require('./snapchat')(ctx),
|
|
178
179
|
soundcloud: require('./soundcloud')(ctx),
|
|
180
|
+
speedrun: require('./speedrun')(ctx),
|
|
179
181
|
spotify: require('./spotify')(ctx),
|
|
180
182
|
stackoverflow: require('./stackoverflow')(ctx),
|
|
181
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
|