-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(route): add gamersky * doc: add default value for 'type' parameter in gamersky news route * fix: type * chore: remove deprecated route * fix: use jsonp api & remove junk * fix: combine duplicated code * fix: restore ent ---------
- Loading branch information
Showing
7 changed files
with
332 additions
and
123 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import type { Route } from '@/types'; | ||
import type { Context } from 'hono'; | ||
import { getArticleList, parseArticleList, getArticle, mdTableBuilder } from './utils'; | ||
|
||
const idNameMap = new Map([ | ||
['all', { title: '热点图文', suffix: 'ent', nodeId: '20107' }], | ||
['qw', { title: '趣囧时间', suffix: 'ent/qw', nodeId: '20113' }], | ||
['movie', { title: '游民影院', suffix: 'wenku/movie', nodeId: '20111' }], | ||
['discovery', { title: '游观天下', suffix: 'ent/discovery', nodeId: '20114' }], | ||
['wp', { title: '壁纸图库', suffix: 'ent/wp', nodeId: '20117' }], | ||
['wenku', { title: '游民盘点', suffix: 'wenku', nodeId: '20106' }], | ||
['xz', { title: '游民福利', suffix: 'ent/xz', nodeId: '20119' }], | ||
]); | ||
|
||
export const route: Route = { | ||
path: '/ent/:category?', | ||
categories: ['game'], | ||
example: '/gamersky/ent/xz', | ||
parameters: { | ||
type: '分类类型,留空为 `all`', | ||
}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: Object.entries(idNameMap).map(([type, { title, suffix }]) => ({ | ||
title, | ||
source: [`www.gamersky.com/${suffix}`], | ||
target: `/ent/${type}`, | ||
})), | ||
name: '娱乐', | ||
maintainers: ['LogicJake'], | ||
description: mdTableBuilder(Object.entries(idNameMap).map(([type, { title, nodeId }]) => ({ type, name: title, nodeId }))), | ||
handler, | ||
}; | ||
|
||
async function handler(ctx: Context) { | ||
const category = ctx.req.param('category') ?? 'all'; | ||
|
||
const idName = idNameMap.get(category); | ||
if (!idName) { | ||
throw new Error(`Invalid type: ${category}`); | ||
} | ||
|
||
const response = await getArticleList(idName.nodeId); | ||
const list = parseArticleList(response); | ||
const fullTextList = await Promise.all(list.map((item) => getArticle(item))); | ||
return { | ||
title: `${idName.title} - 游民娱乐`, | ||
link: `https://www.gamersky.com/${idName.suffix}`, | ||
item: fullTextList, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'GamerSky', | ||
url: 'gamersky.com', | ||
|
||
zh: { | ||
name: '游民星空', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import type { Route } from '@/types'; | ||
import type { Context } from 'hono'; | ||
import { getArticleList, parseArticleList, getArticle, mdTableBuilder } from './utils'; | ||
|
||
const idNameMap = [ | ||
{ | ||
type: 'today', | ||
name: '今日推荐', | ||
nodeId: '11007', | ||
}, | ||
{ | ||
name: '单机电玩', | ||
type: 'pc', | ||
nodeId: '129', | ||
}, | ||
{ | ||
name: 'NS', | ||
type: 'ns', | ||
nodeId: '21160', | ||
}, | ||
{ | ||
name: '手游', | ||
type: 'mobile', | ||
nodeId: '20260', | ||
}, | ||
{ | ||
name: '网游', | ||
type: 'web', | ||
nodeId: '20225', | ||
}, | ||
{ | ||
name: '业界', | ||
type: 'industry', | ||
nodeId: '21163', | ||
}, | ||
{ | ||
name: '硬件', | ||
type: 'hardware', | ||
nodeId: '20070', | ||
}, | ||
{ | ||
name: '科技', | ||
type: 'tech', | ||
nodeId: '20547', | ||
}, | ||
]; | ||
|
||
export const route: Route = { | ||
path: '/news/:type?', | ||
categories: ['game'], | ||
example: '/gamersky/news/pc', | ||
parameters: { | ||
type: '资讯类型,见表,默认为 `pc`', | ||
}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.gamersky.com/news'], | ||
target: '/news', | ||
}, | ||
], | ||
name: '资讯', | ||
maintainers: ['yy4382'], | ||
description: mdTableBuilder(idNameMap), | ||
handler, | ||
}; | ||
|
||
async function handler(ctx: Context) { | ||
const type = ctx.req.param('type') ?? 'pc'; | ||
|
||
const idName = idNameMap.find((item) => item.type === type); | ||
if (!idName) { | ||
throw new Error(`Invalid type: ${type}`); | ||
} | ||
|
||
const response = await getArticleList(idName.nodeId); | ||
const list = parseArticleList(response); | ||
const fullTextList = await Promise.all(list.map((item) => getArticle(item))); | ||
return { | ||
title: `${idName.name} - 游民星空`, | ||
link: 'https://www.gamersky.com/news', | ||
item: fullTextList, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import type { Route } from '@/types'; | ||
import type { Context } from 'hono'; | ||
import { getArticleList, parseArticleList, getArticle, mdTableBuilder } from './utils'; | ||
const idNameMap = [ | ||
{ | ||
type: 'pc', | ||
name: '单机', | ||
nodeId: '20465', | ||
}, | ||
{ | ||
type: 'tv', | ||
name: '电视', | ||
nodeId: '20466', | ||
}, | ||
{ | ||
type: 'indie', | ||
name: '独立游戏', | ||
nodeId: '20922', | ||
}, | ||
{ | ||
type: 'web', | ||
name: '网游', | ||
nodeId: '20916', | ||
}, | ||
{ | ||
type: 'mobile', | ||
name: '手游', | ||
nodeId: '20917', | ||
}, | ||
{ | ||
type: 'all', | ||
name: '全部评测', | ||
nodeId: '20915', | ||
}, | ||
]; | ||
|
||
export const route: Route = { | ||
path: '/review/:type?', | ||
categories: ['game'], | ||
example: '/gamersky/review/pc', | ||
parameters: { | ||
type: '评测类型,可选值为 `pc`、`tv`、`indie`、`web`、`mobile`、`all`,默认为 `pc`', | ||
}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.gamersky.com/review'], | ||
target: '/review', | ||
}, | ||
], | ||
name: '评测', | ||
maintainers: ['yy4382'], | ||
description: mdTableBuilder(idNameMap), | ||
handler, | ||
}; | ||
|
||
async function handler(ctx: Context) { | ||
const type = ctx.req.param('type') ?? 'pc'; | ||
|
||
const idName = idNameMap.find((item) => item.type === type); | ||
if (!idName) { | ||
throw new Error(`Invalid type: ${type}`); | ||
} | ||
|
||
const response = await getArticleList(idName.nodeId); | ||
const list = parseArticleList(response); | ||
const fullTextList = await Promise.all(list.map((item) => getArticle(item))); | ||
return { | ||
title: `${idName.name} - 游民星空评测`, | ||
link: 'https://www.gamersky.com/review', | ||
item: fullTextList, | ||
}; | ||
} |
Oops, something went wrong.