From 418e68aa57b36a5c6e6db4816fcd204c555a9a38 Mon Sep 17 00:00:00 2001 From: huanfei <41602338+huanfe1@users.noreply.github.com> Date: Sun, 14 Jan 2024 17:35:00 +0800 Subject: [PATCH] fix: pornhub pubDate (#14232) --- lib/v2/pornhub/utils.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/v2/pornhub/utils.js b/lib/v2/pornhub/utils.js index 10d4af2b46..1dc21ff9a5 100644 --- a/lib/v2/pornhub/utils.js +++ b/lib/v2/pornhub/utils.js @@ -1,6 +1,7 @@ const { art } = require('@/utils/render'); const { join } = require('path'); const { parseRelativeDate } = require('@/utils/parse-date'); +const dayjs = require('dayjs'); const defaultDomain = 'https://www.pornhub.com'; @@ -10,6 +11,10 @@ const headers = { }; const renderDescription = (data) => art(join(__dirname, 'templates/description.art'), data); +const extractDateFromImageUrl = (imageUrl) => { + const matchResult = imageUrl.match(/(\d{6})\/(\d{2})/); + return matchResult ? matchResult.slice(1, 3).join('') : null; +}; const parseItems = (e) => ({ title: e.find('span.title a').text().trim(), @@ -19,7 +24,7 @@ const parseItems = (e) => ({ previewVideo: e.find('img').data('mediabook'), }), author: e.find('.usernameWrap a').text(), - pubDate: parseRelativeDate(e.find('.added').text()), + pubDate: dayjs(extractDateFromImageUrl(e.find('img').data('mediumthumb'))) || parseRelativeDate(e.find('.added').text()), }); module.exports = {