metascraper-spotify 5.29.15 → 5.30.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.
Files changed (2) hide show
  1. package/index.js +23 -4
  2. package/package.json +6 -6
package/index.js CHANGED
@@ -6,12 +6,19 @@ const memoize = require('@keyvhq/memoize')
6
6
  const got = require('got')
7
7
 
8
8
  const {
9
- sanetizeUrl,
9
+ $jsonld,
10
+ author,
10
11
  composeRule,
12
+ description,
11
13
  memoizeOne,
12
- normalizeUrl
14
+ normalizeUrl,
15
+ sanetizeUrl,
16
+ toRule
13
17
  } = require('@metascraper/helpers')
14
18
 
19
+ const toDescription = toRule(description)
20
+ const toAuthor = toRule(author)
21
+
15
22
  const { getPreview } = require('spotify-url-info')((url, opts) =>
16
23
  got(url, opts).then(res => ({
17
24
  text: () => Promise.resolve(res.body)
@@ -43,9 +50,21 @@ module.exports = ({ gotOpts, keyvOpts } = {}) => {
43
50
 
44
51
  const rules = {
45
52
  audio: getSpotify({ from: 'audio', ext: 'mp3' }),
46
- author: getSpotify({ from: 'artist', to: 'author' }),
53
+ author: [
54
+ toAuthor($jsonld('publisher')),
55
+ getSpotify({ from: 'artist', to: 'author' })
56
+ ],
47
57
  date: getSpotify({ from: 'date' }),
48
- description: getSpotify({ from: 'description' }),
58
+ description: [
59
+ toDescription($ => {
60
+ const raw = $('meta[property="og:description"]').attr('content')
61
+ if (!raw) return
62
+ const [, description] = raw.split('on Spotify. ')
63
+ return description
64
+ }),
65
+
66
+ getSpotify({ from: 'description' })
67
+ ],
49
68
  image: getSpotify({ from: 'image' }),
50
69
  publisher: () => 'Spotify',
51
70
  title: getSpotify({ from: 'title' }),
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.29.15",
5
+ "version": "5.30.3",
6
6
  "main": "index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -24,11 +24,11 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@keyvhq/memoize": "~1.6.14",
27
- "@metascraper/helpers": "^5.29.15",
28
- "async-memoize-one": "~1.1.1",
27
+ "@metascraper/helpers": "^5.30.3",
28
+ "async-memoize-one": "~1.1.2",
29
29
  "got": "~11.8.5",
30
- "spotify-url-info": "~3.1.2",
31
- "tldts": "~5.7.84"
30
+ "spotify-url-info": "~3.1.3",
31
+ "tldts": "~5.7.87"
32
32
  },
33
33
  "devDependencies": {
34
34
  "ava": "latest",
@@ -51,5 +51,5 @@
51
51
  "!test/helpers.js"
52
52
  ]
53
53
  },
54
- "gitHead": "e58e9a45bdbb474198f0d4f3100fdae17729ea44"
54
+ "gitHead": "f671b1b622e4f6f20f9a75a2beeb1afcf9301d31"
55
55
  }