Skip to content

Commit

Permalink
fix(route/kcna): Remove juche date parsing (#17694)
Browse files Browse the repository at this point in the history
* fix(route/kcna): Remove juche date parsing

* Update news.ts

* Update news.ts

* Update news.ts
  • Loading branch information
dzx-dzx authored Nov 24, 2024
1 parent 334a197 commit ab5b967
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/routes/kcna/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import asyncPool from 'tiny-async-pool';
import { art } from '@/utils/render';
import { parseJucheDate, fixDesc, fetchPhoto, fetchVideo } from './utils';
import { fixDesc, fetchPhoto, fetchVideo } from './utils';
import path from 'node:path';
import sanitizeHtml from 'sanitize-html';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';

export const route: Route = {
path: '/:lang/:category?',
Expand Down Expand Up @@ -66,12 +68,12 @@ async function handler(ctx) {
.map((_, item) => {
item = $(item);
const dateElem = item.find('.publish-time');
const dateString = dateElem.text();
const dateString = dateElem.text().match(/\d+\.\d+\.\d+/);
dateElem.remove();
return {
title: item.text(),
link: rootUrl + item.attr('href'),
pubDate: parseJucheDate(dateString),
pubDate: timezone(parseDate(dateString[0]), +9),
};
})
.get();
Expand All @@ -87,9 +89,9 @@ async function handler(ctx) {
item.title = $('article-main-title').text() || item.title;

const dateElem = $('.publish-time');
const dateString = dateElem.text();
const dateString = dateElem.text().match(/\d+\.\d+\.\d+/);
dateElem.remove();
item.pubDate = parseJucheDate(dateString) || item.pubDate;
item.pubDate = dateString ? timezone(parseDate(dateString[0]), +9) : item.pubDate;

const description = fixDesc($, $('.article-content-body .content-wrapper'));

Expand Down

0 comments on commit ab5b967

Please sign in to comment.