mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
feat: add view
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import parser from '@/utils/rss-parser';
|
||||
import { fetchArticle } from './utils';
|
||||
const HOME_PAGE = 'https://apnews.com';
|
||||
@@ -7,6 +7,7 @@ export const route: Route = {
|
||||
path: '/rss/:category?',
|
||||
categories: ['traditional-media', 'popular'],
|
||||
example: '/apnews/rss/business',
|
||||
view: ViewType.Articles,
|
||||
parameters: {
|
||||
category: {
|
||||
description: 'Category from the first segment of the corresponding site, or `index` for the front page.',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { fetchArticle, removeDuplicateByKey } from './utils';
|
||||
@@ -8,6 +8,7 @@ export const route: Route = {
|
||||
path: '/topics/:topic?',
|
||||
categories: ['traditional-media', 'popular'],
|
||||
example: '/apnews/topics/apf-topnews',
|
||||
view: ViewType.Articles,
|
||||
parameters: {
|
||||
topic: {
|
||||
description: 'Topic name, can be found in URL. For example: the topic name of AP Top News [https://apnews.com/apf-topnews](https://apnews.com/apf-topnews) is `apf-topnews`',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import JSONbig from 'json-bigint';
|
||||
@@ -11,6 +11,7 @@ import { BilibiliWebDynamicResponse, Item2, Modules } from './api-interface';
|
||||
export const route: Route = {
|
||||
path: '/user/dynamic/:uid/:routeParams?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.SocialMedia,
|
||||
example: '/bilibili/user/dynamic/2267573',
|
||||
parameters: {
|
||||
uid: '用户 id, 可在 UP 主主页中找到',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import utils from './utils';
|
||||
|
||||
@@ -7,6 +7,7 @@ export const route: Route = {
|
||||
name: '排行榜',
|
||||
maintainers: ['DIYgod'],
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.Videos,
|
||||
example: '/bilibili/ranking/0/3/1',
|
||||
parameters: {
|
||||
rid: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import cache from './cache';
|
||||
import utils from './utils';
|
||||
@@ -7,6 +7,7 @@ import logger from '@/utils/logger';
|
||||
export const route: Route = {
|
||||
path: '/user/video/:uid/:disableEmbed?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.Videos,
|
||||
example: '/bilibili/user/video/2267573',
|
||||
parameters: { uid: '用户 id, 可在 UP 主主页中找到', disableEmbed: '默认为开启内嵌视频, 任意值为关闭' },
|
||||
features: {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { hash } from './utils';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/build/:owner/:image/:tag?',
|
||||
categories: ['program-update', 'popular'],
|
||||
view: ViewType.Notifications,
|
||||
example: '/dockerhub/build/diygod/rsshub',
|
||||
parameters: {
|
||||
owner: 'Image owner, the owner of the official image fills in the library, for example: /dockerhub/build/library/mysql',
|
||||
|
||||
@@ -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';
|
||||
@@ -6,6 +6,7 @@ import { load } from 'cheerio';
|
||||
export const route: Route = {
|
||||
path: '/group/:groupid/:type?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.SocialMedia,
|
||||
example: '/douban/group/648102',
|
||||
parameters: {
|
||||
groupid: '豆瓣小组的 id',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import InvalidParameterError from '@/errors/types/invalid-parameter';
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
@@ -9,6 +9,7 @@ import ConfigNotFoundError from '@/errors/types/config-not-found';
|
||||
export const route: Route = {
|
||||
path: '/timeline/:account',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.SocialMedia,
|
||||
example: '/fediverse/timeline/Mastodon@mastodon.social',
|
||||
parameters: { account: 'username@domain' },
|
||||
features: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { config } from '@/config';
|
||||
import MarkdownIt from 'markdown-it';
|
||||
@@ -12,6 +12,7 @@ import { parseDate } from '@/utils/parse-date';
|
||||
export const route: Route = {
|
||||
path: '/issue/:user/:repo/:state?/:labels?',
|
||||
categories: ['programming', 'popular'],
|
||||
view: ViewType.Notifications,
|
||||
example: '/github/issue/DIYgod/RSSHub/open',
|
||||
parameters: {
|
||||
user: 'GitHub username',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import { ig, login } from './utils';
|
||||
import logger from '@/utils/logger';
|
||||
@@ -59,6 +59,7 @@ async function loadContent(category, nameOrId, tryGet) {
|
||||
export const route: Route = {
|
||||
path: '/:category/:key',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.SocialMedia,
|
||||
example: '/instagram/user/stefaniejoosten',
|
||||
parameters: {
|
||||
category: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import { getCurrentPath } from '@/utils/helpers';
|
||||
const __dirname = getCurrentPath(import.meta.url);
|
||||
|
||||
@@ -30,6 +30,7 @@ export const route: Route = {
|
||||
name: 'Works',
|
||||
maintainers: ['MegrezZhu', 'CoderTonyChan', 'nczitzk', 'Felix2yu'],
|
||||
categories: ['multimedia', 'popular'],
|
||||
view: ViewType.Videos,
|
||||
handler,
|
||||
url: 'www.javbus.com',
|
||||
example: '/javbus/star/rwt',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import InvalidParameterError from '@/errors/types/invalid-parameter';
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { isValidHost } from '@/utils/valid-host';
|
||||
@@ -8,6 +8,7 @@ export const route: Route = {
|
||||
path: '/user/:name?',
|
||||
categories: ['social-media', 'popular'],
|
||||
example: '/lofter/user/i',
|
||||
view: ViewType.Articles,
|
||||
parameters: { name: 'Lofter user name, can be found in the URL' },
|
||||
features: {
|
||||
requireConfig: false,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import { getToken } from './token';
|
||||
import getRanking from './api/get-ranking';
|
||||
@@ -61,6 +61,7 @@ const alias = {
|
||||
export const route: Route = {
|
||||
path: '/ranking/:mode/:date?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.Pictures,
|
||||
example: '/pixiv/ranking/week',
|
||||
parameters: {
|
||||
mode: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import { getToken } from './token';
|
||||
import searchPopularIllust from './api/search-popular-illust';
|
||||
@@ -11,6 +11,7 @@ import ConfigNotFoundError from '@/errors/types/config-not-found';
|
||||
export const route: Route = {
|
||||
path: '/search/:keyword/:order?/:mode?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.Pictures,
|
||||
example: '/pixiv/search/Nezuko/popular',
|
||||
parameters: {
|
||||
keyword: 'keyword',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import { getToken } from './token';
|
||||
import getIllusts from './api/get-illusts';
|
||||
@@ -10,6 +10,7 @@ import ConfigNotFoundError from '@/errors/types/config-not-found';
|
||||
export const route: Route = {
|
||||
path: '/user/:id',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.Pictures,
|
||||
example: '/pixiv/user/15288095',
|
||||
parameters: { id: "user id, available in user's homepage URL" },
|
||||
features: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import { getCurrentPath } from '@/utils/helpers';
|
||||
const __dirname = getCurrentPath(import.meta.url);
|
||||
|
||||
@@ -12,6 +12,7 @@ import path from 'node:path';
|
||||
export const route: Route = {
|
||||
path: '/:category/:topic?',
|
||||
categories: ['traditional-media', 'popular'],
|
||||
view: ViewType.Articles,
|
||||
example: '/reuters/world/us',
|
||||
parameters: { category: 'find it in the URL, or tables below', topic: 'find it in the URL, or tables below' },
|
||||
features: {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/routes/:lang?',
|
||||
categories: ['program-update', 'popular'],
|
||||
view: ViewType.Notifications,
|
||||
example: '/rsshub/routes/en',
|
||||
parameters: {
|
||||
lang: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import { getCurrentPath } from '@/utils/helpers';
|
||||
import cache from '@/utils/cache';
|
||||
import { config } from '@/config';
|
||||
@@ -58,6 +58,7 @@ const mediaTagDict = {
|
||||
export const route: Route = {
|
||||
path: '/channel/:username/:routeParams?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.SocialMedia,
|
||||
example: '/telegram/channel/awesomeRSSHub',
|
||||
parameters: {
|
||||
username: 'channel username',
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import api from './api';
|
||||
import utils from './utils';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/keyword/:keyword/:routeParams?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.SocialMedia,
|
||||
example: '/twitter/keyword/RSSHub',
|
||||
parameters: { keyword: 'keyword', routeParams: 'extra parameters, see the table above' },
|
||||
features: {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import api from './api';
|
||||
import utils from './utils';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/media/:id/:routeParams?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.Pictures,
|
||||
example: '/twitter/media/_RSSHub',
|
||||
parameters: { id: 'username; in particular, if starts with `+`, it will be recognized as a [unique ID](https://github.com/DIYgod/RSSHub/issues/12221), e.g. `+44196397`', routeParams: 'extra parameters, see the table above.' },
|
||||
features: {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import utils from './utils';
|
||||
import api from './api';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/user/:id/:routeParams?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.SocialMedia,
|
||||
example: '/twitter/user/_RSSHub',
|
||||
parameters: {
|
||||
id: 'username; in particular, if starts with `+`, it will be recognized as a [unique ID](https://github.com/DIYgod/RSSHub/issues/12221), e.g. `+44196397`',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import querystring from 'querystring';
|
||||
import got from '@/utils/got';
|
||||
@@ -10,6 +10,7 @@ import { config } from '@/config';
|
||||
export const route: Route = {
|
||||
path: '/keyword/:keyword/:routeParams?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.SocialMedia,
|
||||
example: '/weibo/keyword/RSSHub',
|
||||
parameters: { keyword: '你想订阅的微博关键词', routeParams: '额外参数;请参阅上面的说明和表格' },
|
||||
features: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import querystring from 'querystring';
|
||||
import got from '@/utils/got';
|
||||
@@ -11,6 +11,7 @@ import { fallback, queryToBoolean } from '@/utils/readable-social';
|
||||
export const route: Route = {
|
||||
path: '/user/:uid/:routeParams?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.SocialMedia,
|
||||
example: '/weibo/user/1195230310',
|
||||
parameters: { uid: '用户 id, 博主主页打开控制台执行 `$CONFIG.oid` 获取', routeParams: '额外参数;请参阅上面的说明和表格;特别地,当 `routeParams=1` 时开启微博视频显示' },
|
||||
features: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
@@ -6,6 +6,7 @@ import { parseDate } from '@/utils/parse-date';
|
||||
export const route: Route = {
|
||||
path: '/podcast/:id',
|
||||
categories: ['multimedia', 'popular'],
|
||||
view: ViewType.Audios,
|
||||
example: '/xiaoyuzhou/podcast/6021f949a789fca4eff4492c',
|
||||
parameters: { id: '播客id,可以在小宇宙播客的 URL 中找到' },
|
||||
features: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import utils from './utils';
|
||||
import { config } from '@/config';
|
||||
@@ -10,6 +10,7 @@ import ConfigNotFoundError from '@/errors/types/config-not-found';
|
||||
export const route: Route = {
|
||||
path: '/user/:username/:embed?',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.Videos,
|
||||
example: '/youtube/user/@JFlaMusic',
|
||||
parameters: { username: 'YouTuber username with @', embed: 'Default to embed the video, set to any value to disable embedding' },
|
||||
features: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from '@/types';
|
||||
import { Route, ViewType } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { header, processImage, getSignedHeader } from './utils';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
@@ -6,6 +6,7 @@ import { parseDate } from '@/utils/parse-date';
|
||||
export const route: Route = {
|
||||
path: '/people/activities/:id',
|
||||
categories: ['social-media', 'popular'],
|
||||
view: ViewType.Articles,
|
||||
example: '/zhihu/people/activities/diygod',
|
||||
parameters: { id: '作者 id,可在用户主页 URL 中找到' },
|
||||
features: {
|
||||
|
||||
@@ -125,6 +125,15 @@ interface Namespace extends NamespaceItem {
|
||||
|
||||
export type { Namespace };
|
||||
|
||||
export enum ViewType {
|
||||
Articles = 0,
|
||||
SocialMedia = 1,
|
||||
Pictures = 2,
|
||||
Videos = 3,
|
||||
Audios = 4,
|
||||
Notifications = 5,
|
||||
}
|
||||
|
||||
// route
|
||||
interface RouteItem {
|
||||
/**
|
||||
@@ -223,6 +232,11 @@ interface RouteItem {
|
||||
* The [RSSHub-Radar](https://github.com/DIYgod/RSSHub-Radar) rule of the route
|
||||
*/
|
||||
radar?: RadarItem[];
|
||||
|
||||
/**
|
||||
* The [Follow](https://github.com/RSSNext/follow) default view of the route, default to `ViewType.Articles`
|
||||
*/
|
||||
view?: ViewType;
|
||||
}
|
||||
|
||||
interface Route extends RouteItem {
|
||||
|
||||
Reference in New Issue
Block a user