metascraper-youtube 5.45.10 → 5.45.22

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.
package/README.md CHANGED
@@ -27,4 +27,4 @@ Any option provided here will passed to [got#options](https://github.com/sindres
27
27
  **metascraper-youtube** © [Microlink](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/metascraper/blob/master/LICENSE.md) License.<br>
28
28
  Authored and maintained by [Microlink](https://microlink.io) with help from [contributors](https://github.com/microlinkhq/metascraper/contributors).
29
29
 
30
- > [microlink.io](https://microlink.io) · GitHub [microlinkhq](https://github.com/microlinkhq) · Twitter [@microlinkhq](https://twitter.com/microlinkhq)
30
+ > [microlink.io](https://microlink.io) · GitHub [microlinkhq](https://github.com/microlinkhq) · X [@microlinkhq](https://x.com/microlinkhq)
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "metascraper-youtube",
3
3
  "description": "Metascraper integration with YouTube",
4
4
  "homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-youtube",
5
- "version": "5.45.10",
5
+ "version": "5.45.22",
6
6
  "types": "src/index.d.ts",
7
7
  "main": "src/index.js",
8
8
  "author": {
@@ -24,7 +24,7 @@
24
24
  "youtube"
25
25
  ],
26
26
  "dependencies": {
27
- "@metascraper/helpers": "^5.45.10",
27
+ "@metascraper/helpers": "^5.45.22",
28
28
  "get-video-id": "~3.6.5",
29
29
  "p-locate": "~5.0.0",
30
30
  "reachable-url": "~1.8.1"
@@ -48,5 +48,5 @@
48
48
  "!test/helpers.js"
49
49
  ]
50
50
  },
51
- "gitHead": "dba98fa823be9b495ed8935c094d41de6184f578"
51
+ "gitHead": "d934045034f25536eec414edf4f5be0b2b73d7ed"
52
52
  }
package/src/index.js CHANGED
@@ -1,10 +1,17 @@
1
1
  'use strict'
2
2
 
3
- const { $filter, author, toRule, memoizeOne } = require('@metascraper/helpers')
4
3
  const reachableUrl = require('reachable-url')
5
4
  const getVideoId = require('get-video-id')
6
5
  const pLocate = require('p-locate')
7
6
 
7
+ const {
8
+ $filter,
9
+ author,
10
+ memoizeOne,
11
+ title,
12
+ toRule
13
+ } = require('@metascraper/helpers')
14
+
8
15
  const THUMBAILS_RESOLUTIONS = [
9
16
  'maxresdefault.jpg',
10
17
  'sddefault.jpg',
@@ -25,12 +32,15 @@ const getThumbnailUrl = (id, gotOpts) => {
25
32
 
26
33
  const toAuthor = toRule(author)
27
34
 
35
+ const toTitle = toRule(title)
36
+
28
37
  const getVideoInfo = memoizeOne(getVideoId)
29
38
 
30
39
  const test = memoizeOne(url => getVideoInfo(url).service === 'youtube')
31
40
 
32
41
  module.exports = ({ gotOpts } = {}) => {
33
42
  const rules = {
43
+ title: [toTitle($ => $('title').text().replace(' - YouTube', ''))],
34
44
  author: [
35
45
  toAuthor($ => $filter($, $('[class*="user-info" i]'))),
36
46
  toAuthor($ => $('[itemprop="author"] [itemprop="name"]').attr('content'))