File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
packages/metascraper-youtube Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ const { isString } = require('lodash')
7
7
8
8
const getThumbnailUrl = id => `https://i.ytimg.com/vi/${ id } /maxresdefault.jpg`
9
9
10
+ const getVideo = url => getVideoId ( url ) || { }
11
+
10
12
const wrap = rule => ( { htmlDom } ) => {
11
13
const value = rule ( htmlDom )
12
14
return isString ( value ) && ! isUrl ( value , { relative : false } ) && titleize (
@@ -21,11 +23,11 @@ module.exports = () => ({
21
23
wrap ( $ => getValue ( $ , $ ( '[class*="user-info"]' ) ) )
22
24
] ,
23
25
publisher : [
24
- ( { url} ) => getVideoId ( url ) . service === 'youtube' && 'YouTube'
26
+ ( { url} ) => getVideo ( url ) . service === 'youtube' && 'YouTube'
25
27
] ,
26
28
image : [
27
29
( { htmlDom, url } ) => {
28
- const { id, service} = getVideoId ( url )
30
+ const { id, service} = getVideo ( url )
29
31
return service === 'youtube' && id && getThumbnailUrl ( id )
30
32
}
31
33
]
You can’t perform that action at this time.
0 commit comments