Skip to content

Commit

Permalink
feat(route): add WebCatalog changelog (#17981)
Browse files Browse the repository at this point in the history
* feat(route): add WebCatalog changelog

* fix: add guid
  • Loading branch information
Tsuyumi25 authored Dec 26, 2024
1 parent 8cd5311 commit 5cef7df
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
59 changes: 59 additions & 0 deletions lib/routes/webcatalog/changelog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Route } from '@/types';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import ofetch from '@/utils/ofetch';

export const route: Route = {
path: '/changelog',
categories: ['program-update'],
example: '/webcatalog/changelog',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['desktop.webcatalog.io/:lang/changelog'],
},
],
name: 'Changelog',
maintainers: ['Tsuyumi25'],
handler,
url: 'desktop.webcatalog.io/en/changelog',
};

async function handler() {
const url = 'https://desktop.webcatalog.io/en/changelog';
const response = await ofetch(url);
const $ = load(response);

// remove What's new
$('.container article div.mb-20').remove();
const items = $('.container article')
.html()
?.split('<hr>')
?.map((section) => {
const $section = load(section);
const month = $section('h1').remove().text();
const title = $section('h2').first().remove().text();
return {
title: `${month} - ${title}`,
description: $section.html(),
link: url,
pubDate: parseDate(month),
guid: `webcatalog-${month}-${title}`,
};
});

return {
title: 'WebCatalog Changelog',
link: url,
item: items,
language: 'en',
};
}
7 changes: 7 additions & 0 deletions lib/routes/webcatalog/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'WebCatalog',
url: 'desktop.webcatalog.io',
lang: 'en',
};

0 comments on commit 5cef7df

Please sign in to comment.