Skip to content

Commit

Permalink
fix(route): fix warthunder route pubDate parse (#17324)
Browse files Browse the repository at this point in the history
  • Loading branch information
axojhf authored Oct 27, 2024
1 parent a71410f commit 5e7fc99
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/routes/warthunder/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Route } from '@/types';
import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);

import got from '@/utils/got';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import path from 'node:path';
import { art } from '@/utils/render';
Expand Down Expand Up @@ -33,20 +33,21 @@ export const route: Route = {
handler,
url: 'warthunder.com/en/news',
description: `News data from [https://warthunder.com/en/news/](https://warthunder.com/en/news/)
The year, month and day provided under UTC time zone are the same as the official website, so please ignore the specific time!!!`,
The \`pubDate\` provided under UTC time zone, so please ignore the specific time!!!`,
};

async function handler() {
const rootUrl = 'https://warthunder.com/en/news/';

const response = await got(rootUrl);
const response = await ofetch(rootUrl);

const $ = load(response.data);
const $ = load(response);

const pageFace = $('div.showcase__item.widget')
.map((_, item) => {
.toArray()
.map((item) => {
item = $(item);
let pubDate = parseDate(item.find('div.widget__content > ul > li.widget-meta__item.widget-meta__item--right').text(), 'D MMMM YYYY');
let pubDate = parseDate(item.find('div.widget__content > ul > li.widget-meta__item.widget-meta__item--right').text(), 'D MMMM YYYY', 'en');
pubDate = timezone(pubDate, 0);
const category = [];
if (item.find('div.widget__pin').length !== 0) {
Expand All @@ -68,8 +69,7 @@ async function handler() {
}),
category,
};
})
.get();
});

return {
title: 'War Thunder News',
Expand Down

0 comments on commit 5e7fc99

Please sign in to comment.