Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/metascraper-youtube/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const test = memoizeOne(url => getVideoInfo(url).service === 'youtube')

module.exports = ({ gotOpts } = {}) => {
const rules = {
title: [toTitle($ => $('title').text().replace(' - YouTube', ''))],
title: [toTitle($ => $('title:first').text().replace(' - YouTube', ''))],
author: [
toAuthor($ => $filter($, $('[class*="user-info" i]'))),
toAuthor($ => $('[itemprop="author"] [itemprop="name"]').attr('content'))
Expand Down
84 changes: 84 additions & 0 deletions packages/metascraper-youtube/test/fixtures/youtube-title.html

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/metascraper-youtube/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,11 @@ test('youtube list', async t => {
const metadata = await metascraper({ html, url })
t.snapshot(metadata)
})

test('dedupe youtube title', async t => {
const html = await readFile(resolve(__dirname, 'fixtures/youtube-title.html'))
const url = 'https://www.youtube.com/watch?v=hwMkbaS_M_c'

const metadata = await metascraper({ html, url })
t.snapshot(metadata)
})
16 changes: 16 additions & 0 deletions packages/metascraper-youtube/test/snapshots/index.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,19 @@ Generated by [AVA](https://avajs.dev).
title: 'Marine Biologist - Career Spotlight',
url: 'https://www.youtube.com/watch?v=EAZvxukW8kY&list=PLDB4BCE9817AE7B43&index=11',
}

## dedupe youtube title

> Snapshot 1

{
author: 'Global Brain',
date: '2025-03-28T00:55:38.000Z',
description: 'The Global Brain Alliance Forum (GBAF) is a conference where participants explore the latest trends surrounding startups, bringing together startups and larg…',
image: 'https://img.youtube.com/vi/hwMkbaS_M_c/maxresdefault.jpg',
lang: 'es',
logo: 'https://www.youtube.com/s/desktop/2f190eaf/img/favicon_144x144.png',
publisher: 'YouTube',
title: 'GBAF 2024 – Highlights',
url: 'https://www.youtube.com/watch?v=DIsktwOQZuU',
}
Binary file modified packages/metascraper-youtube/test/snapshots/index.js.snap
Binary file not shown.
Loading