@unavatar/core 3.56.0 → 3.57.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
@@ -66,6 +66,7 @@
66
66
  - [npm](#npm)
67
67
  - [OnlyFans](#onlyfans)
68
68
  - [OpenStreetMap](#openstreetmap)
69
+ - [osu!](#osu)
69
70
  - [Patreon](#patreon)
70
71
  - [PayPal](#paypal)
71
72
  - [Pinterest](#pinterest)
@@ -937,6 +938,15 @@ Available inputs:
937
938
  - Numeric user ID, e.g., [unavatar.io/openstreetmap/98672](https://unavatar.io/openstreetmap/98672)
938
939
  - Username, e.g., [unavatar.io/openstreetmap/Terence%20Eden](https://unavatar.io/openstreetmap/Terence%20Eden)
939
940
 
941
+ ### osu!
942
+
943
+ Get any osu! player's profile picture by their username or numeric user ID.
944
+
945
+ Available inputs:
946
+
947
+ - Username, e.g., [unavatar.io/osu/peppy](https://unavatar.io/osu/peppy)
948
+ - Numeric user ID, e.g., [unavatar.io/osu/7562902](https://unavatar.io/osu/7562902)
949
+
940
950
  ### Patreon
941
951
 
942
952
  Get any Patreon creator's profile picture by their 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.56.0",
5
+ "version": "3.57.0",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
@@ -45,6 +45,7 @@ const providerTiers = {
45
45
  'npm',
46
46
  'onlyfans',
47
47
  'openstreetmap',
48
+ 'osu',
48
49
  'patreon',
49
50
  'paypal',
50
51
  'pinterest',
@@ -143,6 +144,7 @@ module.exports = ctx => {
143
144
  npm: require('./npm')(ctx),
144
145
  onlyfans: require('./onlyfans')(ctx),
145
146
  openstreetmap: require('./openstreetmap')(ctx),
147
+ osu: require('./osu')(ctx),
146
148
  patreon: require('./patreon')(ctx),
147
149
  paypal: require('./paypal')(ctx),
148
150
  pinterest: require('./pinterest')(ctx),
@@ -0,0 +1,23 @@
1
+ 'use strict'
2
+
3
+ const PROFILE_URL = 'https://osu.ppy.sh/users'
4
+ const UPLOADED_AVATAR_ORIGIN = 'https://a.ppy.sh/'
5
+
6
+ const isUploadedAvatar = url => url.startsWith(UPLOADED_AVATAR_ORIGIN)
7
+
8
+ const getAvatarUrl = input => `${PROFILE_URL}/${encodeURIComponent(input)}`
9
+
10
+ const getAvatar = ({ $, getOgImage, NOT_FOUND }) => {
11
+ const image = getOgImage($)
12
+ return image && isUploadedAvatar(image) ? image : NOT_FOUND
13
+ }
14
+
15
+ module.exports = ({ createHtmlProvider, getOgImage, NOT_FOUND }) =>
16
+ createHtmlProvider({
17
+ name: 'osu',
18
+ url: getAvatarUrl,
19
+ getter: $ => getAvatar({ $, getOgImage, NOT_FOUND })
20
+ })
21
+
22
+ module.exports.getAvatarUrl = getAvatarUrl
23
+ module.exports.getAvatar = getAvatar