1
1
'use strict'
2
2
3
- const { overEvery, isEmpty, eq, has, round, size, get, chain, find, isString } = require ( 'lodash' )
3
+ const {
4
+ overEvery,
5
+ isEmpty,
6
+ eq,
7
+ has,
8
+ round,
9
+ size,
10
+ get,
11
+ chain,
12
+ find,
13
+ isString
14
+ } = require ( 'lodash' )
4
15
const { isUrl, titleize } = require ( '@metascraper/helpers' )
5
16
const path = require ( 'path' )
6
17
7
18
const getVideoInfo = require ( './get-video-info' )
8
19
9
20
const isMp4 = video =>
10
- eq ( get ( video , 'ext' ) , 'mp4' ) || path . extname ( get ( video , 'url' ) ) . startsWith ( '.mp4' )
21
+ eq ( get ( video , 'ext' ) , 'mp4' ) ||
22
+ path . extname ( get ( video , 'url' ) ) . startsWith ( '.mp4' )
11
23
const isHttp = video => eq ( get ( video , 'protocol' ) , 'http' )
12
24
const isHttps = video => eq ( get ( video , 'protocol' ) , 'https' )
13
25
const hasAudio = video => has ( video , 'abr' )
@@ -37,8 +49,7 @@ const getVideoProvider = async ({ url }) => {
37
49
getVideoUrl ( formats , [ isMp4 , isHttps , hasAudio ] ) ||
38
50
getVideoUrl ( formats , [ isMp4 , isHttp , hasAudio ] ) ||
39
51
getVideoUrl ( formats , [ isMp4 , isHttps ] ) ||
40
- getVideoUrl ( formats , [ isMp4 ] ) ||
41
- getVideoUrl ( formats )
52
+ getVideoUrl ( formats , [ isMp4 ] )
42
53
43
54
return isUrl ( videoUrl ) && videoUrl
44
55
}
@@ -61,7 +72,9 @@ const getVideoPublisher = async ({ url }) => {
61
72
}
62
73
63
74
const getVideoTitle = async ( { url } ) => {
64
- const { title : mainTitle , alt_title : secondaryTitle } = await getVideoInfo ( url )
75
+ const { title : mainTitle , alt_title : secondaryTitle } = await getVideoInfo (
76
+ url
77
+ )
65
78
const title = find ( [ mainTitle , secondaryTitle ] , isString )
66
79
return title && titleize ( title )
67
80
}
0 commit comments