metascraper-audio 5.49.25 → 5.50.1
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/package.json +3 -3
- package/src/index.js +3 -28
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "metascraper-audio",
|
|
3
3
|
"description": "Get audio property from HTML markup",
|
|
4
4
|
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-audio",
|
|
5
|
-
"version": "5.
|
|
5
|
+
"version": "5.50.1",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"author": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"metascraper"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@metascraper/helpers": "5.
|
|
26
|
+
"@metascraper/helpers": "5.50.1",
|
|
27
27
|
"lodash": "~4.17.23",
|
|
28
28
|
"p-reflect": "~2.1.0"
|
|
29
29
|
},
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"!test/helpers.js"
|
|
48
48
|
]
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "688ff08cd5618a0fd9afa55e31552e95136814f2"
|
|
51
51
|
}
|
package/src/index.js
CHANGED
|
@@ -4,9 +4,10 @@ const {
|
|
|
4
4
|
$filter,
|
|
5
5
|
$jsonld,
|
|
6
6
|
audio,
|
|
7
|
+
createGetIframeCached,
|
|
8
|
+
defaultGetIframe,
|
|
7
9
|
findRule,
|
|
8
10
|
has,
|
|
9
|
-
loadIframe,
|
|
10
11
|
normalizeUrl,
|
|
11
12
|
toRule
|
|
12
13
|
} = require('@metascraper/helpers')
|
|
@@ -67,33 +68,7 @@ const audioRules = [
|
|
|
67
68
|
({ htmlDom: $ }) => $filter($, $('a[href]'), el => audio(el.attr('href')))
|
|
68
69
|
]
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
loadIframe(url, $.load(`<iframe src="${src}"></iframe>`))
|
|
72
|
-
|
|
73
|
-
const createGetIframeCached = getIframe => {
|
|
74
|
-
const cacheByHtmlDom = new WeakMap()
|
|
75
|
-
|
|
76
|
-
return async (url, $, src) => {
|
|
77
|
-
let cacheBySrc = cacheByHtmlDom.get($)
|
|
78
|
-
if (!cacheBySrc) {
|
|
79
|
-
cacheBySrc = new Map()
|
|
80
|
-
cacheByHtmlDom.set($, cacheBySrc)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const cachedHtmlDom = cacheBySrc.get(src)
|
|
84
|
-
if (cachedHtmlDom) return cachedHtmlDom
|
|
85
|
-
|
|
86
|
-
const pendingHtmlDom = getIframe(url, $, { src }).catch(error => {
|
|
87
|
-
cacheBySrc.delete(src)
|
|
88
|
-
throw error
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
cacheBySrc.set(src, pendingHtmlDom)
|
|
92
|
-
return pendingHtmlDom
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
module.exports = ({ getIframe = _getIframe } = {}) => {
|
|
71
|
+
module.exports = ({ getIframe = defaultGetIframe } = {}) => {
|
|
97
72
|
const getIframeCached = createGetIframeCached(getIframe)
|
|
98
73
|
const rules = {
|
|
99
74
|
audio: audioRules.concat(
|