fix: pornhub pubDate (#14232)

This commit is contained in:
huanfei
2024-01-14 09:35:00 +00:00
committed by GitHub
parent 376ebf4bc4
commit 418e68aa57
+6 -1
View File
@@ -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 = {