Skip to content

Commit f6fd92a

Browse files
committed
At least video need to be mp4 format
1 parent b012514 commit f6fd92a

File tree

1 file changed

+18
-5
lines changed
  • packages/metascraper-video-provider/src

1 file changed

+18
-5
lines changed

packages/metascraper-video-provider/src/index.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
'use strict'
22

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')
415
const { isUrl, titleize } = require('@metascraper/helpers')
516
const path = require('path')
617

718
const getVideoInfo = require('./get-video-info')
819

920
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')
1123
const isHttp = video => eq(get(video, 'protocol'), 'http')
1224
const isHttps = video => eq(get(video, 'protocol'), 'https')
1325
const hasAudio = video => has(video, 'abr')
@@ -37,8 +49,7 @@ const getVideoProvider = async ({ url }) => {
3749
getVideoUrl(formats, [isMp4, isHttps, hasAudio]) ||
3850
getVideoUrl(formats, [isMp4, isHttp, hasAudio]) ||
3951
getVideoUrl(formats, [isMp4, isHttps]) ||
40-
getVideoUrl(formats, [isMp4]) ||
41-
getVideoUrl(formats)
52+
getVideoUrl(formats, [isMp4])
4253

4354
return isUrl(videoUrl) && videoUrl
4455
}
@@ -61,7 +72,9 @@ const getVideoPublisher = async ({ url }) => {
6172
}
6273

6374
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+
)
6578
const title = find([mainTitle, secondaryTitle], isString)
6679
return title && titleize(title)
6780
}

0 commit comments

Comments
 (0)