Skip to content

Commit

Permalink
Ensure output is an object
Browse files Browse the repository at this point in the history
rollback that after radiovisual/get-video-id#15
  • Loading branch information
Kikobeats committed Jan 23, 2018
1 parent 93d81c9 commit dbfac33
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/metascraper-youtube/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const { isString } = require('lodash')

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

const getVideo = url => getVideoId(url) || {}

const wrap = rule => ({ htmlDom }) => {
const value = rule(htmlDom)
return isString(value) && !isUrl(value, {relative: false}) && titleize(
Expand All @@ -21,11 +23,11 @@ module.exports = () => ({
wrap($ => getValue($, $('[class*="user-info"]')))
],
publisher: [
({url}) => getVideoId(url).service === 'youtube' && 'YouTube'
({url}) => getVideo(url).service === 'youtube' && 'YouTube'
],
image: [
({ htmlDom, url }) => {
const {id, service} = getVideoId(url)
const {id, service} = getVideo(url)
return service === 'youtube' && id && getThumbnailUrl(id)
}
]
Expand Down

0 comments on commit dbfac33

Please sign in to comment.