Skip to content

Commit dbfac33

Browse files
committed
Ensure output is an object
rollback that after radiovisual/get-video-id#15
1 parent 93d81c9 commit dbfac33

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/metascraper-youtube/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const { isString } = require('lodash')
77

88
const getThumbnailUrl = id => `https://i.ytimg.com/vi/${id}/maxresdefault.jpg`
99

10+
const getVideo = url => getVideoId(url) || {}
11+
1012
const wrap = rule => ({ htmlDom }) => {
1113
const value = rule(htmlDom)
1214
return isString(value) && !isUrl(value, {relative: false}) && titleize(
@@ -21,11 +23,11 @@ module.exports = () => ({
2123
wrap($ => getValue($, $('[class*="user-info"]')))
2224
],
2325
publisher: [
24-
({url}) => getVideoId(url).service === 'youtube' && 'YouTube'
26+
({url}) => getVideo(url).service === 'youtube' && 'YouTube'
2527
],
2628
image: [
2729
({ htmlDom, url }) => {
28-
const {id, service} = getVideoId(url)
30+
const {id, service} = getVideo(url)
2931
return service === 'youtube' && id && getThumbnailUrl(id)
3032
}
3133
]

0 commit comments

Comments
 (0)