metascraper-spotify 5.25.7 → 5.26.3
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 +12 -0
- package/index.js +10 -4
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -11,6 +11,18 @@
|
|
|
11
11
|
$ npm install metascraper-spotify --save
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
## API
|
|
15
|
+
|
|
16
|
+
### metascraper-spotify([options])
|
|
17
|
+
|
|
18
|
+
#### options
|
|
19
|
+
|
|
20
|
+
##### gotOpts
|
|
21
|
+
|
|
22
|
+
Type: `object`
|
|
23
|
+
|
|
24
|
+
Any option provided here will passed to [got#options](https://github.com/sindresorhus/got#options).
|
|
25
|
+
|
|
14
26
|
## License
|
|
15
27
|
|
|
16
28
|
**metascraper-spotify** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/metascraper/blob/master/LICENSE.md) License.<br>
|
package/index.js
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
const { composeRule, memoizeOne } = require('@metascraper/helpers')
|
|
4
4
|
const asyncMemoizeOne = require('async-memoize-one')
|
|
5
5
|
const { getDomainWithoutSuffix } = require('tldts')
|
|
6
|
-
const
|
|
6
|
+
const got = require('got')
|
|
7
|
+
|
|
8
|
+
const { getPreview } = require('spotify-url-info')((url, opts) =>
|
|
9
|
+
got(url, opts).then(res => ({
|
|
10
|
+
text: () => Promise.resolve(res.body)
|
|
11
|
+
}))
|
|
12
|
+
)
|
|
7
13
|
|
|
8
14
|
const spotify = asyncMemoizeOne(async url => {
|
|
9
15
|
try {
|
|
@@ -13,11 +19,11 @@ const spotify = asyncMemoizeOne(async url => {
|
|
|
13
19
|
}
|
|
14
20
|
})
|
|
15
21
|
|
|
16
|
-
const getSpotify = composeRule(($, url) => spotify(url))
|
|
17
|
-
|
|
18
22
|
const isValidUrl = memoizeOne(url => getDomainWithoutSuffix(url) === 'spotify')
|
|
19
23
|
|
|
20
|
-
module.exports = () => {
|
|
24
|
+
module.exports = ({ gotOpts } = {}) => {
|
|
25
|
+
const getSpotify = composeRule(($, url) => spotify(url, gotOpts))
|
|
26
|
+
|
|
21
27
|
const rules = {
|
|
22
28
|
audio: getSpotify({ from: 'audio', ext: 'mp3' }),
|
|
23
29
|
author: getSpotify({ from: 'artist', to: 'author' }),
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "metascraper-spotify",
|
|
3
3
|
"description": "Metascraper integration with Spotify",
|
|
4
4
|
"homepage": "https://nicedoc.io/microlinkhq/metascraper/packages/metascraper-spotify",
|
|
5
|
-
"version": "5.
|
|
5
|
+
"version": "5.26.3",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -23,10 +23,11 @@
|
|
|
23
23
|
"spotify"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@metascraper/helpers": "^5.
|
|
26
|
+
"@metascraper/helpers": "^5.26.0",
|
|
27
27
|
"async-memoize-one": "~1.1.0",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"got": "~11.8.3",
|
|
29
|
+
"spotify-url-info": "~3.0.0",
|
|
30
|
+
"tldts": "~5.7.70"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"kind-of": "latest",
|
|
@@ -45,5 +46,5 @@
|
|
|
45
46
|
"test": "NODE_PATH=.. TZ=UTC NODE_ENV=test mocha test"
|
|
46
47
|
},
|
|
47
48
|
"license": "MIT",
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "9a69931fa22a94d4b2903731f7043f16d7aed469"
|
|
49
50
|
}
|