Skip to content

Commit

Permalink
feat(route): add more popular traditional news
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudoyu committed Sep 24, 2024
1 parent 44b5b1a commit 0e7fb35
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 49 deletions.
5 changes: 3 additions & 2 deletions lib/routes/caixin/latest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);

Expand All @@ -10,7 +10,8 @@ import path from 'node:path';

export const route: Route = {
path: '/latest',
categories: ['traditional-media'],
categories: ['traditional-media', 'popular'],
view: ViewType.Articles,
example: '/caixin/latest',
parameters: {},
features: {
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/economist/espresso.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
Expand All @@ -8,7 +8,8 @@ const link = 'https://www.economist.com/the-world-in-brief';

export const route: Route = {
path: '/espresso',
categories: ['traditional-media'],
categories: ['traditional-media', 'popular'],
view: ViewType.Articles,
example: '/economist/espresso',
parameters: {},
features: {
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/economist/full.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import cache from '@/utils/cache';
import parser from '@/utils/rss-parser';
import got from '@/utils/got';
Expand All @@ -21,7 +21,8 @@ const getArticleDetail = (link) =>

export const route: Route = {
path: '/:endpoint',
categories: ['traditional-media'],
categories: ['traditional-media', 'popular'],
view: ViewType.Articles,
example: '/economist/latest',
parameters: { endpoint: 'Category name, can be found on the [official page](https://www.economist.com/rss). For example, https://www.economist.com/china/rss.xml to china' },
features: {
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/gq/news.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import cache from '@/utils/cache';
import parser from '@/utils/rss-parser';
import { load } from 'cheerio';
import ofetch from '@/utils/ofetch';
const host = 'https://www.gq.com';
export const route: Route = {
path: '/news',
categories: ['traditional-media'],
categories: ['traditional-media', 'popular'],
view: ViewType.Articles,
example: '/gq/news',
parameters: {},
features: {
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/jianshu/collection.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import util from './utils';

export const route: Route = {
path: '/collection/:id',
categories: ['social-media'],
categories: ['social-media', 'popular'],
view: ViewType.Articles,
example: '/jianshu/collection/xYuZYD',
parameters: { id: '专题 id, 可在专题页 URL 中找到' },
features: {
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/jianshu/home.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import util from './utils';

export const route: Route = {
path: '/home',
categories: ['social-media'],
categories: ['social-media', 'popular'],
view: ViewType.Articles,
example: '/jianshu/home',
parameters: {},
features: {
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/jianshu/user.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import util from './utils';

export const route: Route = {
path: '/user/:id',
categories: ['social-media'],
categories: ['social-media', 'popular'],
example: '/jianshu/user/yZq3ZV',
view: ViewType.Articles,
parameters: { id: '作者 id, 可在作者主页 URL 中找到' },
features: {
requireConfig: false,
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/newyorker/news.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import cache from '@/utils/cache';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';

const host = 'https://www.newyorker.com';
export const route: Route = {
path: '/:category',
categories: ['traditional-media'],
categories: ['traditional-media', 'popular'],
view: ViewType.Articles,
example: '/newyorker/latest',
parameters: { category: 'tab name. can be found at url' },
features: {
Expand Down
36 changes: 32 additions & 4 deletions lib/routes/nhk/news.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);

Expand All @@ -12,9 +12,37 @@ const apiUrl = 'https://nwapi.nhk.jp';

export const route: Route = {
path: '/news/:lang?',
categories: ['traditional-media'],
categories: ['traditional-media', 'popular'],
view: ViewType.Articles,
example: '/nhk/news/en',
parameters: { lang: 'Language, see below, `en` by default' },
parameters: {
lang: {
description: 'Language, see below',
options: [
{ value: 'ar', label: 'العربية' },
{ value: 'bn', label: 'বাংলা' },
{ value: 'my', label: 'မြန်မာဘာသာစကား' },
{ value: 'zh', label: '中文(简体)' },
{ value: 'zt', label: '中文(繁體)' },
{ value: 'en', label: 'English' },
{ value: 'fr', label: 'Français' },
{ value: 'hi', label: 'हिन्दी' },
{ value: 'id', label: 'Bahasa Indonesia' },
{ value: 'ko', label: '코리언' },
{ value: 'fa', label: 'فارسی' },
{ value: 'pt', label: 'Português' },
{ value: 'ru', label: 'Русский' },
{ value: 'es', label: 'Español' },
{ value: 'sw', label: 'Kiswahili' },
{ value: 'th', label: 'ภาษาไทย' },
{ value: 'tr', label: 'Türkçe' },
{ value: 'uk', label: 'Українська' },
{ value: 'ur', label: 'اردو' },
{ value: 'vi', label: 'Tiếng Việt' },
],
default: 'en',
},
},
features: {
requireConfig: false,
requirePuppeteer: false,
Expand All @@ -30,7 +58,7 @@ export const route: Route = {
},
],
name: 'WORLD-JAPAN - Top Stories',
maintainers: ['TonyRL'],
maintainers: ['TonyRL', 'pseudoyu'],
handler,
description: `| العربية | বাংলা | မြန်မာဘာသာစကား | 中文(简体) | 中文(繁體) | English | Français |
| ------- | -- | ------------ | ------------ | ------------ | ------- | -------- |
Expand Down
31 changes: 14 additions & 17 deletions lib/routes/nytimes/book.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';

Expand All @@ -18,9 +18,19 @@ const categoryList = {

export const route: Route = {
path: '/book/:category?',
categories: ['traditional-media'],
categories: ['traditional-media', 'popular'],
view: ViewType.Notifications,
example: '/nytimes/book/combined-print-and-e-book-nonfiction',
parameters: { category: 'N' },
parameters: {
category: {
description: 'Category, can be found on the [official page](https://www.nytimes.com/books/best-sellers/)',
options: Object.keys(categoryList).map((key) => ({
value: key,
label: categoryList[key],
})),
default: 'combined-print-and-e-book-nonfiction',
},
},
features: {
requireConfig: false,
requirePuppeteer: false,
Expand All @@ -36,22 +46,9 @@ export const route: Route = {
},
],
name: 'Best Seller Books',
maintainers: ['melvinto'],
maintainers: ['melvinto', 'pseudoyu'],
handler,
url: 'nytimes.com/',
description: `| Category |
| ------------------------------------ |
| combined-print-and-e-book-nonfiction |
| hardcover-nonfiction |
| paperback-nonfiction |
| advice-how-to-and-miscellaneous |
| combined-print-and-e-book-fiction |
| hardcover-fiction |
| trade-fiction-paperback |
| childrens-middle-grade-hardcover |
| picture-books |
| series-books |
| young-adult-hardcover |`,
};

async function handler(ctx) {
Expand Down
25 changes: 16 additions & 9 deletions lib/routes/nytimes/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import parser from '@/utils/rss-parser';
Expand All @@ -8,9 +8,20 @@ import puppeteer from '@/utils/puppeteer';

export const route: Route = {
path: '/:lang?',
categories: ['traditional-media'],
categories: ['traditional-media', 'popular'],
view: ViewType.Articles,
example: '/nytimes/dual',
parameters: { lang: 'language, default to Chinese' },
parameters: {
lang: {
description: 'language, default to Chinese',
options: [
{ value: 'dual', label: 'Chinese-English' },
{ value: 'en', label: 'English' },
{ value: 'traditionalchinese', label: 'Traditional Chinese' },
{ value: 'dual-traditionalchinese', label: 'Chinese-English (Traditional Chinese)' },
],
},
},
features: {
requireConfig: false,
requirePuppeteer: false,
Expand All @@ -26,14 +37,10 @@ export const route: Route = {
},
],
name: 'News',
maintainers: ['HenryQW'],
maintainers: ['HenryQW', 'pseudoyu'],
handler,
url: 'nytimes.com/',
description: `By extracting the full text of articles, we provide a better reading experience (full text articles) over the official one.
| Default to Chinese | Chinese-English | English | Chinese-English (Traditional Chinese) | Traditional Chinese |
| ------------------ | --------------- | ------- | ------------------------------------- | ------------------- |
| (empty) | dual | en | dual-traditionalchinese | traditionalchinese |`,
description: `By extracting the full text of articles, we provide a better reading experience (full text articles) over the official one.`,
};

async function handler(ctx) {
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/solidot/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import cache from '@/utils/cache';
// Warning: The author still knows nothing about javascript!

Expand All @@ -13,7 +13,8 @@ import InvalidParameterError from '@/errors/types/invalid-parameter';

export const route: Route = {
path: '/:type?',
categories: ['traditional-media'],
categories: ['traditional-media', 'popular'],
view: ViewType.Articles,
example: '/solidot/linux',
parameters: { type: '消息类型。默认为 www. 在网站上方选择后复制子域名即可' },
features: {
Expand Down
4 changes: 3 additions & 1 deletion lib/routes/xiaohongshu/user.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Route } from '@/types';
import { Route, ViewType } from '@/types';
import cache from '@/utils/cache';
import { getUser } from './util';
import InvalidParameterError from '@/errors/types/invalid-parameter';

export const route: Route = {
path: '/user/:user_id/:category',
name: '用户笔记',
categories: ['social-media', 'popular'],
view: ViewType.Articles,
maintainers: ['lotosbin'],
handler,
example: '/xiaohongshu/user/593032945e87e77791e03696/notes',
Expand Down

0 comments on commit 0e7fb35

Please sign in to comment.