Skip to content

Commit 486a964

Browse files
committed
Add youtube case
1 parent 07967ca commit 486a964

File tree

4 files changed

+1375
-1
lines changed

4 files changed

+1375
-1
lines changed

src/get-data/rules/author.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,7 @@ module.exports = [
7979
.filter((i, el) => $(el).text().trim())
8080
.first()
8181
.text()
82-
)
82+
),
83+
84+
wrap($ => $('[class*="user-info"]').text())
8385
]

test/web/youtube/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict'
2+
3+
const {load: loadJSON} = require('json-future')
4+
const {resolve} = require('path')
5+
const {promisify} = require('util')
6+
const should = require('should')
7+
const fs = require('fs')
8+
9+
const getMetaData = require('../../..')
10+
const readFile = promisify(fs.readFile)
11+
12+
it('video', async () => {
13+
const html = await readFile(resolve(__dirname, 'input.html'))
14+
const json = await loadJSON(resolve(__dirname, 'output.json'))
15+
const metadata = await getMetaData(html)
16+
should(metadata).be.deepEqual(json)
17+
})

test/web/youtube/input.html

Lines changed: 1346 additions & 0 deletions
Large diffs are not rendered by default.

test/web/youtube/output.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"author": "Andrew Jrt",
3+
"date": "2017-07-07T00:00:00.000Z",
4+
"description": "👍 Subscribe - http://bit.do/AndrewJRT 🐦 Twitter - https://twitter.com/andrew_jrt 🎮 Twitch - https://twitch.tv/andrewjrt ❤ Patreon - https://www.patreon.com/a...",
5+
"image": "https://i.ytimg.com/vi/GDRd-BFTYIg/maxresdefault.jpg",
6+
"publisher": "YouTube",
7+
"title": "Overwatch - Huge Massive Fist Punch Man",
8+
"url": "https://www.youtube.com/watch?v=GDRd-BFTYIg"
9+
}

0 commit comments

Comments
 (0)