From 6e689c4e0bb5535c77df8d286f3e4d68406f589e Mon Sep 17 00:00:00 2001 From: Joe Wu Date: Thu, 14 Aug 2025 23:34:37 +0800 Subject: [PATCH] fix(route/setn): fix incorrect timezone & title & author (#19778) * fix(route/setn): fix incorrect timezone & title & author - timezone: Timezone error, 8-hour difference - title: Should use complete title from content, as current page title is only a short version - author: Fix data source extraction * refactor: remove IIFE in head JSON parsing * refactor: remove IIFE in head JSON parsing --------- Co-authored-by: Joe Wu --- lib/routes/setn/index.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/routes/setn/index.ts b/lib/routes/setn/index.ts index 63ab5dc92e..4b390a0365 100644 --- a/lib/routes/setn/index.ts +++ b/lib/routes/setn/index.ts @@ -2,6 +2,7 @@ import { Route } from '@/types'; import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; +import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; const defaultRootUrl = 'https://www.setn.com'; @@ -118,11 +119,19 @@ async function handler(ctx) { const content = load(detailResponse.data); + let head = {}; + try { + head = JSON.parse(content('script[type="application/ld+json"]').first().text()); + } catch { + head = {}; + } + content('#gad_setn_innity_oop_1x1').remove(); - item.author = content('meta[property="author"]').attr('content'); + item.title = content('h1').text(); + item.author = head?.author?.name || content('meta[name="author"]').attr('content'); item.category = [content('meta[property="article:section"]').attr('content'), ...content('meta[name="news_keywords"]').attr('content').split(',')]; - item.pubDate = parseDate(content('meta[property="article:published_time"]').attr('content')); + item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), +8); item.description = content('article, .content-p').html(); return item;