metascraper-media-provider 5.40.0 → 5.42.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 +5 -3
- package/src/get-media/provider/generic.js +2 -1
- package/src/index.d.ts +35 -0
package/package.json
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
"name": "metascraper-media-provider",
|
|
3
3
|
"description": "Get video property from HTML markup",
|
|
4
4
|
"homepage": "https://nicedoc.io/microlinkhq/metascraper/packages/metascraper-media-provider",
|
|
5
|
-
"version": "5.
|
|
5
|
+
"version": "5.42.1",
|
|
6
6
|
"main": "src/index.js",
|
|
7
|
+
"types": "src/index.d.ts",
|
|
7
8
|
"author": {
|
|
8
9
|
"email": "hello@microlink.io",
|
|
9
10
|
"name": "microlink.io",
|
|
@@ -32,7 +33,8 @@
|
|
|
32
33
|
"p-reflect": "~2.1.0",
|
|
33
34
|
"p-retry": "~4.6.1",
|
|
34
35
|
"p-timeout": "~4.1.0",
|
|
35
|
-
"
|
|
36
|
+
"serialize-error": "~8.1.0",
|
|
37
|
+
"youtube-dl-exec": "~2.5.2"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
40
|
"@kikobeats/time-span": "latest",
|
|
@@ -58,5 +60,5 @@
|
|
|
58
60
|
"!test/fixtures/generate.js"
|
|
59
61
|
]
|
|
60
62
|
},
|
|
61
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "9235196f519497e588b5537ec60ac75a1f725364"
|
|
62
64
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const debug = require('debug-logfmt')(
|
|
4
4
|
'metascraper-media-provider:provider:generic'
|
|
5
5
|
)
|
|
6
|
+
const { serializeError } = require('serialize-error')
|
|
6
7
|
const youtubedl = require('youtube-dl-exec')
|
|
7
8
|
const { get, constant } = require('lodash')
|
|
8
9
|
const pDoWhilst = require('p-do-whilst')
|
|
@@ -58,7 +59,7 @@ module.exports = ({
|
|
|
58
59
|
const flags = getFlags({ url, proxy, userAgent, cacheDir })
|
|
59
60
|
data = await youtubedl(url, flags, { timeout, ...props })
|
|
60
61
|
} catch (error) {
|
|
61
|
-
if (condition()) debug('getInfo:error', { retryCount }, error)
|
|
62
|
+
if (condition()) { debug('getInfo:error', { retryCount }, serializeError(error)) }
|
|
62
63
|
isSupportedURL = !RE_UNSUPORTED_URL.test(error.stderr)
|
|
63
64
|
}
|
|
64
65
|
}, condition)
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type Options = {
|
|
2
|
+
/**
|
|
3
|
+
* The directory where the youtube-dl binary will be downloaded.
|
|
4
|
+
* @default undefined
|
|
5
|
+
*/
|
|
6
|
+
cacheDir?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Whether to get the proxy from the environment variable.
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
getProxy?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Get the agent from the proxy.
|
|
14
|
+
* @default () => undefined
|
|
15
|
+
*/
|
|
16
|
+
getAgent?: (proxy: string) => object | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The timeout in milliseconds.
|
|
19
|
+
* @default 30000
|
|
20
|
+
*/
|
|
21
|
+
timeout?: number;
|
|
22
|
+
/**
|
|
23
|
+
* The number of retries.
|
|
24
|
+
* @default 2
|
|
25
|
+
*/
|
|
26
|
+
retry?: number;
|
|
27
|
+
/**
|
|
28
|
+
* The options to pass to https://github.com/sindresorhus/got#options
|
|
29
|
+
* @default {}
|
|
30
|
+
*/
|
|
31
|
+
gotOpts: import('got').Options;
|
|
32
|
+
} & import('youtube-dl-exec').Flags;
|
|
33
|
+
|
|
34
|
+
declare function rules(options?: Options): import('metascraper').Rules
|
|
35
|
+
export = rules;
|