Skip to content

Commit

Permalink
fix(author): be sure byline rule is not a date (#410)
Browse files Browse the repository at this point in the history
* fix(author): be sure byline rule is not a date

closes #408

* build: update dependencies
  • Loading branch information
Kikobeats committed May 21, 2021
1 parent 68800c3 commit c8c035d
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/metascraper-amazon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dependencies": {
"@metascraper/helpers": "^5.21.7",
"tldts": "~5.7.29"
"tldts": "~5.7.37"
},
"devDependencies": {
"lodash": "latest",
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-audio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dependencies": {
"@metascraper/helpers": "^5.21.7",
"cheerio": "~1.0.0-rc.6",
"cheerio": "~1.0.0-rc.9",
"got": "~11.8.2",
"p-reflect": "~2.1.0"
},
Expand Down
17 changes: 15 additions & 2 deletions packages/metascraper-author/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
'use strict'

const { $jsonld, $filter, toRule, author } = require('@metascraper/helpers')
const {
$jsonld,
$filter,
toRule,
date,
author
} = require('@metascraper/helpers')

const REGEX_STRICT = /^\S+\s+\S+/

Expand Down Expand Up @@ -32,6 +38,13 @@ module.exports = () => ({
strict(toAuthor($ => $filter($, $('a[href*="/author/" i]')))),
toAuthor($ => $filter($, $('a[class*="screenname" i]'))),
strict(toAuthor($ => $filter($, $('[class*="author" i]')))),
strict(toAuthor($ => $filter($, $('[class*="byline" i]'))))
strict(
toAuthor($ =>
$filter($, $('[class*="byline" i]'), el => {
const value = $filter.fn(el)
return !date(value) && value
})
)
)
]
})
2 changes: 1 addition & 1 deletion packages/metascraper-clearbit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"async-memoize-one": "~1.1.0",
"got": "~11.8.2",
"lodash": "~4.17.21",
"tldts": "~5.7.29"
"tldts": "~5.7.37"
},
"devDependencies": {
"mocha": "latest",
Expand Down
6 changes: 3 additions & 3 deletions packages/metascraper-helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ const titleize = (src, opts = {}) => {
return title
}

const defaultFn = el => el.text().trim()

const $filter = ($, domNodes, fn = defaultFn) => {
const $filter = ($, domNodes, fn = $filter.fn) => {
const el = domNodes.filter((i, el) => fn($(el))).first()
return fn(el)
}

$filter.fn = el => el.text().trim()

const isAuthor = (str, opts = { relative: false }) =>
!isUrl(str, opts) &&
!isEmpty(str) &&
Expand Down
4 changes: 2 additions & 2 deletions packages/metascraper-media-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"p-reflect": "~2.1.0",
"p-retry": "~4.5.0",
"p-timeout": "~4.1.0",
"tldts": "~5.7.29",
"youtube-dl-exec": "~1.2.1"
"tldts": "~5.7.37",
"youtube-dl-exec": "~1.2.3"
},
"devDependencies": {
"is-ci": "latest",
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-soundcloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"dependencies": {
"@metascraper/helpers": "^5.21.7",
"tldts": "~5.7.29"
"tldts": "~5.7.37"
},
"devDependencies": {
"mocha": "latest",
Expand Down
4 changes: 2 additions & 2 deletions packages/metascraper-spotify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"dependencies": {
"@metascraper/helpers": "^5.21.7",
"async-memoize-one": "~1.1.0",
"spotify-url-info": "~2.2.0",
"tldts": "~5.7.29"
"spotify-url-info": "~2.2.2",
"tldts": "~5.7.37"
},
"devDependencies": {
"kind-of": "latest",
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-telegram/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@metascraper/helpers": "^5.21.7",
"async-memoize-one": "~1.1.0",
"css-urls": "~2.0.13",
"tldts": "~5.7.29"
"tldts": "~5.7.37"
},
"devDependencies": {
"mocha": "latest",
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-uol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"dependencies": {
"@metascraper/helpers": "^5.21.7",
"tldts": "~5.7.29"
"tldts": "~5.7.37"
},
"devDependencies": {
"mocha": "latest",
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-video/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dependencies": {
"@metascraper/helpers": "^5.21.7",
"cheerio": "~1.0.0-rc.6",
"cheerio": "~1.0.0-rc.9",
"got": "~11.8.2",
"lodash": "~4.17.21",
"p-reflect": "~2.1.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper/__snapshots__/index.js.snap-shot
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ exports['wired 1'] = {
}

exports['wnycstudios 1'] = {
"author": "August 14, 2020",
"author": null,
"date": "2020-08-14T12:00:00.000Z",
"description": "In the 1980s, as China was modernizing, they ran into a problem. There was no way to fit their 70,000 plus character language on a QWERTY keyboard. Today, the story of how they did it.",
"image": "https://media.wnyc.org/i/1355/1600/c/80/2020/08/QWERTY.JPG",
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
],
"dependencies": {
"@metascraper/helpers": "^5.21.7",
"cheerio": "~1.0.0-rc.6",
"cheerio": "~1.0.0-rc.9",
"lodash": "~4.17.21",
"whoops": "~4.1.0"
},
Expand Down

0 comments on commit c8c035d

Please sign in to comment.