metascraper-media-provider 5.34.10 → 5.35.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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/index.js +25 -16
package/package.json CHANGED
@@ -2,7 +2,7 @@
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.34.10",
5
+ "version": "5.35.1",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -23,7 +23,7 @@
23
23
  "youtube-dl"
24
24
  ],
25
25
  "dependencies": {
26
- "@metascraper/helpers": "^5.34.10",
26
+ "@metascraper/helpers": "^5.35.1",
27
27
  "async-memoize-one": "~1.1.3",
28
28
  "debug-logfmt": "~1.0.4",
29
29
  "got": "~11.8.6",
@@ -42,7 +42,7 @@
42
42
  "unique-random-array": "2"
43
43
  },
44
44
  "engines": {
45
- "node": ">= 12"
45
+ "node": ">= 16"
46
46
  },
47
47
  "files": [
48
48
  "src"
@@ -58,5 +58,5 @@
58
58
  "!test/fixtures/generate.js"
59
59
  ]
60
60
  },
61
- "gitHead": "42dac0d9f4d96b3b9de566df01eebb92e4440df6"
61
+ "gitHead": "9e665d19255a3b6d0f864a96223460c99a5af746"
62
62
  }
package/src/index.js CHANGED
@@ -24,12 +24,19 @@ const {
24
24
 
25
25
  const createGetMedia = require('./get-media')
26
26
 
27
- const isProtocol = value => ({ url }) => eq(protocolFn(url), value)
27
+ const isProtocol =
28
+ value =>
29
+ ({ url }) =>
30
+ eq(protocolFn(url), value)
28
31
 
29
32
  const isHttps = isProtocol('https')
30
33
 
31
- const isMIME = extension => ({ ext, url }) =>
32
- ext ? eq(ext, extension) : eq(extensionFn(url), extension)
34
+ const isMIME =
35
+ extension =>
36
+ ({ ext, url, format }) =>
37
+ ext !== 'unknown_video'
38
+ ? eq(ext, extension)
39
+ : eq(extensionFn(url), extension) || format.includes(extension)
33
40
 
34
41
  const isMp4 = isMIME('mp4')
35
42
  const isMp3 = isMIME('mp3')
@@ -60,19 +67,21 @@ const hasVideo = format =>
60
67
  const isDownloadable = ({ url }) =>
61
68
  new URL(url).searchParams.get('download') === '1'
62
69
 
63
- const getFormatUrls = ({ orderBy }) => (input, filters) => {
64
- const formats = get(input, 'formats') ||
65
- get(input, 'entries[0].formats') || [input]
66
-
67
- const url = chain(formats)
68
- .filter(overEvery(filters))
69
- .orderBy(orderBy, 'asc')
70
- .map('url')
71
- .last()
72
- .value()
73
-
74
- return !isEmpty(url) ? url : undefined
75
- }
70
+ const getFormatUrls =
71
+ ({ orderBy }) =>
72
+ (input, filters) => {
73
+ const formats = get(input, 'formats') ||
74
+ get(input, 'entries[0].formats') || [input]
75
+
76
+ const url = chain(formats)
77
+ .filter(overEvery(filters))
78
+ .orderBy(orderBy, 'asc')
79
+ .map('url')
80
+ .last()
81
+ .value()
82
+
83
+ return !isEmpty(url) ? url : undefined
84
+ }
76
85
 
77
86
  const getVideoUrls = getFormatUrls({ orderBy: 'tbr' })
78
87