metascraper-video 5.42.0 → 5.42.5
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 +5 -5
- package/src/index.d.ts +10 -0
- package/src/index.js +31 -9
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metascraper-video",
|
|
3
3
|
"description": "Get video property from HTML markup",
|
|
4
|
-
"homepage": "https://
|
|
5
|
-
"version": "5.42.
|
|
4
|
+
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-video",
|
|
5
|
+
"version": "5.42.5",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"types": "src/index.d.ts",
|
|
8
8
|
"author": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"video"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@metascraper/helpers": "^5.
|
|
26
|
+
"@metascraper/helpers": "^5.42.5",
|
|
27
27
|
"lodash": "~4.17.21"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"node": ">= 16"
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
|
-
"
|
|
36
|
+
"src"
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
39
|
"test": "NODE_PATH=.. TZ=UTC ava --timeout 15s"
|
|
40
40
|
},
|
|
41
41
|
"license": "MIT",
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "044f875812fff95bba404baad18c087eb154b7b0"
|
|
43
43
|
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type IframeAttributes = {
|
|
2
|
+
src: string
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
type Options = {
|
|
6
|
+
getIframe?: (url: string, htmlDom: import('cheerio').CheerioAPI, iframeAttributes: IframeAttributes) => string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare function rules(options?: Options): import('metascraper').Rules;
|
|
10
|
+
export = rules;
|
package/src/index.js
CHANGED
|
@@ -73,15 +73,37 @@ const _getIframe = (url, $, { src }) =>
|
|
|
73
73
|
loadIframe(url, $.load(`<iframe src="${src}"></iframe>`))
|
|
74
74
|
|
|
75
75
|
const withIframe = (rules, getIframe) =>
|
|
76
|
-
rules.concat(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
rules.concat(
|
|
77
|
+
// async ({ htmlDom: $, url }) => {
|
|
78
|
+
// // TODO: write a test embedding a youtube video as iframe
|
|
79
|
+
// const srcs = [
|
|
80
|
+
// ...new $('iframe[src^="http"], iframe[src^="/"]')
|
|
81
|
+
// .map((_, element) => $(element).attr('src'))
|
|
82
|
+
// .get()
|
|
83
|
+
// .map(src => normalizeUrl(url, src))
|
|
84
|
+
// ]
|
|
85
|
+
// if (srcs.length === 0) return
|
|
86
|
+
// return pReflect(
|
|
87
|
+
// Promise.any(
|
|
88
|
+
// srcs.map(async src => {
|
|
89
|
+
// const htmlDom = await getIframe(url, $, { src })
|
|
90
|
+
// const result = await findRule(audioRules, { htmlDom, url })
|
|
91
|
+
// if (!has(result)) throw TypeError('no result')
|
|
92
|
+
// return result
|
|
93
|
+
// })
|
|
94
|
+
// )
|
|
95
|
+
// ).then(({ value }) => value)
|
|
96
|
+
// },
|
|
97
|
+
async ({ htmlDom: $, url }) => {
|
|
98
|
+
const src = $twitter($, 'twitter:player')
|
|
99
|
+
return src
|
|
100
|
+
? findRule(rules, {
|
|
101
|
+
htmlDom: await getIframe(url, $, { src }),
|
|
102
|
+
url
|
|
103
|
+
})
|
|
104
|
+
: undefined
|
|
105
|
+
}
|
|
106
|
+
)
|
|
85
107
|
|
|
86
108
|
module.exports = ({ getIframe = _getIframe } = {}) => ({
|
|
87
109
|
image: withIframe(imageRules, getIframe),
|