metascraper-youtube 5.45.9 → 5.45.17
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/package.json +3 -3
- package/src/index.js +11 -1
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.
|
|
5
|
+
"version": "5.45.17",
|
|
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.
|
|
27
|
+
"@metascraper/helpers": "^5.45.10",
|
|
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": "
|
|
51
|
+
"gitHead": "517a51e0e7d0df5390053f9feae69d5a4ed7cfb4"
|
|
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'))
|