metascraper-media-provider 5.38.0 → 5.40.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 +4 -4
- package/src/index.js +26 -17
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.
|
|
5
|
+
"version": "5.40.0",
|
|
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.
|
|
26
|
+
"@metascraper/helpers": "^5.40.0",
|
|
27
27
|
"async-memoize-one": "~1.1.3",
|
|
28
28
|
"debug-logfmt": "~1.0.4",
|
|
29
29
|
"got": "~11.8.6",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@kikobeats/time-span": "latest",
|
|
39
|
-
"ava": "
|
|
39
|
+
"ava": "5",
|
|
40
40
|
"parse-proxy-uri": "latest",
|
|
41
41
|
"pretty-ms": "latest",
|
|
42
42
|
"unique-random-array": "2"
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"!test/fixtures/generate.js"
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "b4ec42d7dd7f1bae77c60d60dd8aed4bc5a44fa9"
|
|
62
62
|
}
|
package/src/index.js
CHANGED
|
@@ -68,42 +68,51 @@ const isDownloadable = ({ url }) =>
|
|
|
68
68
|
new URL(url).searchParams.get('download') === '1'
|
|
69
69
|
|
|
70
70
|
const getFormatUrls =
|
|
71
|
-
({ orderBy }) =>
|
|
72
|
-
(input,
|
|
71
|
+
(basicFilters, { orderBy }) =>
|
|
72
|
+
(input, extraFilters, { isStream }) => {
|
|
73
|
+
const filters = extraFilters.concat(basicFilters({ isStream }))
|
|
74
|
+
|
|
73
75
|
const formats = get(input, 'formats') ||
|
|
74
76
|
get(input, 'entries[0].formats') || [input]
|
|
75
77
|
|
|
76
78
|
const url = chain(formats)
|
|
77
79
|
.filter(overEvery(filters))
|
|
78
80
|
.orderBy(orderBy, 'asc')
|
|
79
|
-
.map('url')
|
|
81
|
+
.map(isStream ? 'manifest_url' : 'url')
|
|
80
82
|
.last()
|
|
81
83
|
.value()
|
|
82
84
|
|
|
83
85
|
return !isEmpty(url) ? url : undefined
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
const VIDEO_FILTERS = ({ isStream }) =>
|
|
89
|
+
[
|
|
90
|
+
isStream ? undefined : hasVideo,
|
|
91
|
+
isMp4,
|
|
92
|
+
isHttps,
|
|
93
|
+
negate(isDownloadable),
|
|
94
|
+
isStream ? undefined : negate(isM3u8),
|
|
95
|
+
negate(isMpd),
|
|
96
|
+
isStream ? undefined : hasVideoCodec
|
|
97
|
+
].filter(Boolean)
|
|
98
|
+
|
|
99
|
+
const AUDIO_FILTERS = () => [
|
|
100
|
+
hasAudio,
|
|
93
101
|
isHttps,
|
|
94
102
|
negate(isDownloadable),
|
|
95
|
-
|
|
96
|
-
negate(isMpd),
|
|
97
|
-
hasVideoCodec
|
|
103
|
+
hasAudioCodec
|
|
98
104
|
]
|
|
99
105
|
|
|
100
|
-
const
|
|
106
|
+
const getVideoUrls = getFormatUrls(VIDEO_FILTERS, { orderBy: 'tbr' })
|
|
107
|
+
|
|
108
|
+
const getAudioUrls = getFormatUrls(AUDIO_FILTERS, { orderBy: 'abr' })
|
|
101
109
|
|
|
102
110
|
const getVideo = data =>
|
|
103
|
-
getVideoUrls(data, [hasAudioCodec,
|
|
104
|
-
getVideoUrls(data,
|
|
111
|
+
getVideoUrls(data, [hasAudioCodec], { isStream: false }) ||
|
|
112
|
+
getVideoUrls(data, [], { isStream: false }) ||
|
|
113
|
+
getVideoUrls(data, [], { isStream: true })
|
|
105
114
|
|
|
106
|
-
const getAudio = data => getAudioUrls(data,
|
|
115
|
+
const getAudio = data => getAudioUrls(data, [], { isStream: false })
|
|
107
116
|
|
|
108
117
|
const getAuthor = ({ uploader, creator, uploader_id: uploaderId }) =>
|
|
109
118
|
find([creator, uploader, uploaderId], str => authorFn(str))
|