metascraper-youtube 5.25.0 → 5.25.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +8 -0
  2. package/index.js +8 -5
  3. package/package.json +6 -6
package/README.md CHANGED
@@ -11,6 +11,14 @@
11
11
  $ npm install metascraper-youtube --save
12
12
  ```
13
13
 
14
+ #### options
15
+
16
+ ##### gotOpts
17
+
18
+ Type: `object`
19
+
20
+ Any option provided here will passed to [got#options](https://github.com/sindresorhus/got#options).
21
+
14
22
  ## License
15
23
 
16
24
  **metascraper-youtube** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/metascraper/blob/master/LICENSE.md) License.<br>
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const isReachable = require('is-reachable')
3
+ const reachableUrl = require('reachable-url')
4
4
  const getVideoId = require('get-video-id')
5
5
  const pLocate = require('p-locate')
6
6
 
@@ -20,11 +20,14 @@ const THUMBAILS_RESOLUTIONS = [
20
20
  'default.jpg'
21
21
  ]
22
22
 
23
- const getThumbnailUrl = id => {
23
+ const getThumbnailUrl = (id, gotOpts) => {
24
24
  const urls = THUMBAILS_RESOLUTIONS.map(
25
25
  res => `https://img.youtube.com/vi/${id}/${res}`
26
26
  )
27
- return pLocate(urls, isReachable)
27
+
28
+ return pLocate(urls, async url =>
29
+ reachableUrl.isReachable(await reachableUrl(url, gotOpts))
30
+ )
28
31
  }
29
32
 
30
33
  const toAuthor = toRule(author)
@@ -35,7 +38,7 @@ const getVideoInfo = memoizeOne(getVideoId)
35
38
 
36
39
  const isValidUrl = memoizeOne(url => getVideoInfo(url).service === 'youtube')
37
40
 
38
- module.exports = () => {
41
+ module.exports = ({ gotOpts } = {}) => {
39
42
  const rules = {
40
43
  author: [
41
44
  toAuthor($ => $filter($, $('#owner-name'))),
@@ -47,7 +50,7 @@ module.exports = () => {
47
50
  image: [
48
51
  ({ url }) => {
49
52
  const { id } = getVideoId(url)
50
- return id && getThumbnailUrl(id)
53
+ return id && getThumbnailUrl(id, gotOpts)
51
54
  }
52
55
  ]
53
56
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "metascraper-youtube",
3
3
  "description": "Metascraper integration with YouTube",
4
4
  "homepage": "https://nicedoc.io/microlinkhq/metascraper/packages/metascraper-youtube",
5
- "version": "5.25.0",
5
+ "version": "5.25.5",
6
6
  "main": "index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -23,10 +23,10 @@
23
23
  "youtube"
24
24
  ],
25
25
  "dependencies": {
26
- "@metascraper/helpers": "^5.25.0",
27
- "get-video-id": "~3.4.1",
28
- "is-reachable": "~5.1.0",
29
- "p-locate": "~5.0.0"
26
+ "@metascraper/helpers": "^5.25.5",
27
+ "get-video-id": "~3.4.3",
28
+ "p-locate": "~5.0.0",
29
+ "reachable-url": "~1.6.3"
30
30
  },
31
31
  "devDependencies": {
32
32
  "lodash": "latest",
@@ -45,5 +45,5 @@
45
45
  "test": "NODE_PATH=.. TZ=UTC NODE_ENV=test nyc mocha test"
46
46
  },
47
47
  "license": "MIT",
48
- "gitHead": "bd741119b783e48d3e90ad81a14c25e86886fc07"
48
+ "gitHead": "67c05340a580c2ebd90fe04a02f39b56509b1ec2"
49
49
  }