Skip to content

Commit

Permalink
feat(route): add 歪脑 (DIYgod#18262)
Browse files Browse the repository at this point in the history
* add wainao

* wainao-reads

* Update lib/routes/wainao/wainao-reads.ts

Change category

Co-authored-by: Tony <[email protected]>

* Update lib/routes/wainao/wainao-reads.ts

Remove url https

Co-authored-by: Tony <[email protected]>

* Update lib/routes/wainao/wainao-reads.ts

Remove url http

Co-authored-by: Tony <[email protected]>

* cleanup

---------
  • Loading branch information
lucky13820 authored Feb 4, 2025
1 parent 0a5792b commit a73b28b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/routes/wainao/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '歪脑',
url: 'wainao.me',
description: '歪脑是为讲中文的年轻一代度身定制的新闻杂志。',
lang: 'zh-CN',
};
49 changes: 49 additions & 0 deletions lib/routes/wainao/wainao-reads.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Route } from '@/types';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
path: '/wainao-reads',
categories: ['new-media'],
example: '/wainao/wainao-reads',
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
url: 'www.wainao.me',
name: '歪脑读',
maintainers: ['lucky13820'],
radar: [
{
source: ['www.wainao.me', 'www.wainao.me/wainao-reads'],
target: '/wainao-reads',
},
],
handler,
};

async function handler() {
const apiUrl = 'https://www.wainao.me/pf/api/v3/content/fetch/content-api-collections?query={"content_alias":"wainao-hero"}&d=81&_website=wainao';
const baseUrl = 'https://www.wainao.me';

const response = await got(apiUrl);
const data = JSON.parse(response.body);

const items = data.content_elements.map((item) => ({
title: item.headlines.basic,
description: item.description?.basic || '',
link: baseUrl + item.canonical_url,
pubDate: parseDate(item.publish_date),
image: item.promo_items?.basic?.url || '',
}));

return {
title: '歪脑读 - 歪脑',
link: baseUrl,
item: items,
};
}

0 comments on commit a73b28b

Please sign in to comment.