metascraper-audio 5.52.0 → 5.54.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/package.json +13 -5
- package/src/index.js +3 -34
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metascraper-audio",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "Metascraper rule to extract the audio from HTML using Open Graph, JSON-LD, and fallback selectors.",
|
|
4
4
|
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-audio",
|
|
5
|
-
"version": "5.
|
|
5
|
+
"version": "5.54.0",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"author": {
|
|
@@ -20,10 +20,18 @@
|
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"audio",
|
|
23
|
-
"
|
|
23
|
+
"extract",
|
|
24
|
+
"html",
|
|
25
|
+
"json-ld",
|
|
26
|
+
"media",
|
|
27
|
+
"metadata",
|
|
28
|
+
"metascraper",
|
|
29
|
+
"og:audio",
|
|
30
|
+
"open-graph",
|
|
31
|
+
"scraper"
|
|
24
32
|
],
|
|
25
33
|
"dependencies": {
|
|
26
|
-
"@metascraper/helpers": "5.
|
|
34
|
+
"@metascraper/helpers": "5.54.0",
|
|
27
35
|
"p-reflect": "~3.1.0"
|
|
28
36
|
},
|
|
29
37
|
"devDependencies": {
|
|
@@ -46,5 +54,5 @@
|
|
|
46
54
|
"!test/helpers.js"
|
|
47
55
|
]
|
|
48
56
|
},
|
|
49
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "23db3208c1dcc6367a705bdb9bf723fbaae259e0"
|
|
50
58
|
}
|
package/src/index.js
CHANGED
|
@@ -6,10 +6,8 @@ const {
|
|
|
6
6
|
audio,
|
|
7
7
|
createGetIframeCached,
|
|
8
8
|
defaultGetIframe,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
normalizeUrl,
|
|
12
|
-
toRule
|
|
9
|
+
toRule,
|
|
10
|
+
withIframe
|
|
13
11
|
} = require('@metascraper/helpers')
|
|
14
12
|
|
|
15
13
|
const toAudio = toRule(audio)
|
|
@@ -71,36 +69,7 @@ const audioRules = [
|
|
|
71
69
|
module.exports = ({ getIframe = defaultGetIframe } = {}) => {
|
|
72
70
|
const getIframeCached = createGetIframeCached(getIframe)
|
|
73
71
|
const rules = {
|
|
74
|
-
audio: audioRules
|
|
75
|
-
async ({ htmlDom: $, url }) => {
|
|
76
|
-
const srcs = $('iframe[src^="http"], iframe[src^="/"]')
|
|
77
|
-
.map((_, element) => $(element).attr('src'))
|
|
78
|
-
.get()
|
|
79
|
-
if (srcs.length === 0) return
|
|
80
|
-
const seenSrcs = new Set()
|
|
81
|
-
for (const src of srcs) {
|
|
82
|
-
try {
|
|
83
|
-
const normalizedSrc = normalizeUrl(url, src)
|
|
84
|
-
if (!normalizedSrc) continue
|
|
85
|
-
if (seenSrcs.has(normalizedSrc)) continue
|
|
86
|
-
seenSrcs.add(normalizedSrc)
|
|
87
|
-
|
|
88
|
-
const htmlDom = await getIframeCached(url, $, normalizedSrc)
|
|
89
|
-
const result = await findRule(audioRules, { htmlDom, url })
|
|
90
|
-
if (has(result)) return result
|
|
91
|
-
} catch (_) {}
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
async ({ htmlDom: $, url }) => {
|
|
95
|
-
const src = $('meta[name="twitter:player"]').attr('content')
|
|
96
|
-
return src
|
|
97
|
-
? findRule(audioRules, {
|
|
98
|
-
htmlDom: await getIframeCached(url, $, src),
|
|
99
|
-
url
|
|
100
|
-
})
|
|
101
|
-
: undefined
|
|
102
|
-
}
|
|
103
|
-
)
|
|
72
|
+
audio: withIframe(audioRules, getIframeCached, 'audio')
|
|
104
73
|
}
|
|
105
74
|
|
|
106
75
|
rules.pkgName = 'metascraper-audio'
|