forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix(route): taptap * fix(route): correct language code formatting in TapTap routes
- Loading branch information
1 parent
8162dd0
commit e513f6c
Showing
13 changed files
with
722 additions
and
290 deletions.
There are no files selected for viewing
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,29 @@ | ||
import { Route } from '@/types'; | ||
import { handler } from './common/changelog'; | ||
|
||
export const route: Route = { | ||
path: '/changelog/:id/:lang?', | ||
categories: ['game'], | ||
example: '/taptap/changelog/60809/en_US', | ||
parameters: { | ||
id: '游戏 ID,游戏主页 URL 中获取', | ||
lang: '语言,默认使用 `zh_CN`,亦可使用 `en_US`', | ||
}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.taptap.cn/app/:id'], | ||
target: '/changelog/:id', | ||
}, | ||
], | ||
name: '游戏更新', | ||
maintainers: ['hoilc', 'ETiV'], | ||
handler, | ||
}; |
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,34 @@ | ||
import { Route } from '@/types'; | ||
import { handler } from './common/changelog'; | ||
|
||
export const route: Route = { | ||
path: '/intl/changelog/:id/:lang?', | ||
categories: ['game'], | ||
example: '/taptap/intl/changelog/191001/zh_TW', | ||
parameters: { | ||
id: "Game's App ID, you may find it from the URL of the Game", | ||
lang: 'Language, checkout the table below for possible values, default is `en_US`', | ||
}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.taptap.io/app/:id'], | ||
target: '/intl/changelog/:id', | ||
}, | ||
], | ||
name: "Game's Changelog", | ||
maintainers: ['hoilc', 'ETiV'], | ||
handler, | ||
description: `Language Code | ||
| English (US) | 繁體中文 | 한국어 | 日本語 | | ||
| ------------ | -------- | ------ | ------ | | ||
| en_US | zh_TW | ko_KR | ja_JP |`, | ||
}; |
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,40 @@ | ||
import ofetch from '@/utils/ofetch'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import { getRootUrl, appDetail, X_UA } from '../utils'; | ||
|
||
export async function handler(ctx) { | ||
const requestPath = ctx.req.path.replace('/taptap', ''); | ||
const isIntl = requestPath.startsWith('/intl/'); | ||
const id = ctx.req.param('id'); | ||
const lang = ctx.req.param('lang') ?? (isIntl ? 'en_US' : 'zh_CN'); | ||
|
||
const url = `${getRootUrl(isIntl)}/app/${id}`; | ||
|
||
const detail = await appDetail(id, lang, isIntl); | ||
|
||
const appImg = detail.app.icon.original_url; | ||
const appName = detail.app.title; | ||
const appDescription = `${appName}${detail.app.developers ? ' by' + detail.app.developers.map((item) => item.name).join(' & ') : ''}`; | ||
|
||
const response = await ofetch(`${getRootUrl(isIntl)}/webapiv2/apk/v1/list-by-app?app_id=${id}&from=0&limit=10&${X_UA(lang)}`, { | ||
headers: { | ||
Referer: url, | ||
}, | ||
}); | ||
|
||
const list = response.data.list; | ||
|
||
return { | ||
title: `TapTap 更新记录 ${appName}`, | ||
description: appDescription, | ||
link: url, | ||
image: appImg, | ||
item: list.map((item) => ({ | ||
title: `${appName} / ${item.version_label}`, | ||
description: item.whatsnew.text, | ||
pubDate: parseDate(item.update_date, 'X'), | ||
link: url, | ||
guid: item.version_label, | ||
})), | ||
}; | ||
} |
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,126 @@ | ||
import ofetch from '@/utils/ofetch'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import { getRootUrl, appDetail, X_UA } from '../utils'; | ||
|
||
/* | ||
const sortMap = { | ||
default: { | ||
en_US: 'Default', | ||
zh_CN: '预设', | ||
zh_TW: '預設', | ||
}, | ||
recent: { | ||
en_US: 'Latest', | ||
zh_CN: '最新', | ||
zh_TW: '最新', | ||
}, | ||
hot: { | ||
en_US: 'Popular', | ||
zh_CN: '热门', | ||
zh_TW: '熱門', | ||
}, | ||
spent: { | ||
en_US: 'Play Time', | ||
zh_CN: '游戏时长', | ||
zh_TW: '遊戲時長', | ||
}, | ||
}; | ||
const intlSortMap = { | ||
helpful: { | ||
en_US: 'Most Helpful', | ||
zh_TW: '最有幫助', | ||
ja_JP: '最も役立つ', | ||
ko_KR: '가장 도움이 된', | ||
}, | ||
recent: { | ||
en_US: 'Most Recent', | ||
zh_TW: '最新', | ||
ja_JP: '最も最近', | ||
ko_KR: '최근순', | ||
}, | ||
}; | ||
*/ | ||
|
||
const makeSortParam = (isIntl: boolean, order: string) => { | ||
if (isIntl) { | ||
if (order === 'helpful' || order === 'recent') { | ||
return `type=${order}`; | ||
} | ||
return 'type=helpful'; | ||
} else { | ||
if (order === 'new' || order === 'hot') { | ||
return `sort=${order}`; | ||
} | ||
return 'sort=hot'; | ||
} | ||
}; | ||
|
||
const fetchMainlandItems = async (params) => { | ||
const id = params.id; | ||
const order = params.order ?? 'hot'; | ||
const lang = params.lang ?? 'zh_CN'; | ||
|
||
let url = `${getRootUrl(false)}/webapiv2/review/v2/list-by-app?app_id=${id}&limit=10`; | ||
url += `&${makeSortParam(false, order)}`; | ||
url += `&${X_UA(lang)}`; | ||
|
||
const reviewListResponse = await ofetch(url); | ||
|
||
return reviewListResponse.data.list.map((review) => { | ||
const author = review.moment.author.user.name; | ||
const score = review.moment.review.score; | ||
return { | ||
title: `${author} - ${score}星`, | ||
author, | ||
description: review.moment.review.contents.text + (review.moment.review.contents.images ? review.moment.review.contents.images.map((img) => `<img src="${img.original_url}">`).join('') : ''), | ||
link: `${getRootUrl(false)}/review/${review.moment.review.id}`, | ||
pubDate: parseDate(review.moment.publish_time, 'X'), | ||
}; | ||
}); | ||
}; | ||
|
||
const fetchIntlItems = async (params) => { | ||
const id = params.id; | ||
const order = params.order ?? 'helpful'; | ||
const lang = params.lang ?? 'en_US'; | ||
|
||
let url = `${getRootUrl(true)}/webapiv2/feeds/v3/by-app?app_id=${id}&limit=10`; | ||
url += `&${makeSortParam(true, order)}`; | ||
url += `&${X_UA(lang)}`; | ||
|
||
const reviewListResponse = await ofetch(url); | ||
|
||
return reviewListResponse.data.list.map((review) => { | ||
const author = review.post.user.name; | ||
const score = review.post.list_fields.app_ratings[id].score; | ||
return { | ||
title: `${author} - ${'★'.repeat(score)}`, | ||
author, | ||
description: review.post.list_fields.summary || review.post.list_fields.title, | ||
link: `${getRootUrl(true)}/post/${review.post.id_str}`, | ||
pubDate: parseDate(review.post.published_time, 'X'), | ||
}; | ||
}); | ||
}; | ||
|
||
export async function handler(ctx) { | ||
const requestPath = ctx.req.path.replace('/taptap', ''); | ||
const isIntl = requestPath.startsWith('/intl/'); | ||
const id = ctx.req.param('id'); | ||
const order = ctx.req.param('order') ?? 'default'; | ||
const lang = ctx.req.param('lang') ?? (isIntl ? 'en_US' : 'zh_CN'); | ||
|
||
const detail = await appDetail(id, lang, isIntl); | ||
const appImg = detail.app.icon.original_url; | ||
const appName = detail.app.title; | ||
|
||
const items = isIntl ? await fetchIntlItems({ id, order, lang }) : await fetchMainlandItems({ id, order, lang }); | ||
|
||
return { | ||
title: `TapTap 评价 ${appName}`, | ||
link: `${getRootUrl(isIntl)}/app/${id}/review?${makeSortParam(isIntl, order)}`, | ||
image: appImg, | ||
item: items, | ||
}; | ||
} |
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
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,33 @@ | ||
import { Route } from '@/types'; | ||
import { handler } from './common/review'; | ||
|
||
export const route: Route = { | ||
path: '/review/:id/:order?/:lang?', | ||
categories: ['game'], | ||
example: '/taptap/review/142793/hot', | ||
parameters: { | ||
id: '游戏 ID,游戏主页 URL 中获取', | ||
order: '排序方式,空为综合,可选如下', | ||
lang: '语言,`zh-CN` 或 `zh-TW`,默认为 `zh-CN`', | ||
}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.taptap.cn/app/:id/review', 'www.taptap.cn/app/:id'], | ||
target: '/review/:id', | ||
}, | ||
], | ||
name: '游戏评价', | ||
maintainers: ['hoilc', 'TonyRL'], | ||
handler, | ||
description: `| 最新 | 综合 | | ||
| --- | --- | | ||
| new | hot |`, | ||
}; |
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,41 @@ | ||
import { Route } from '@/types'; | ||
import { handler } from './common/review'; | ||
|
||
export const route: Route = { | ||
path: '/intl/review/:id/:order?/:lang?', | ||
categories: ['game'], | ||
example: '/taptap/intl/review/82354/recent', | ||
parameters: { | ||
id: "Game's App ID, you may find it from the URL of the Game", | ||
order: 'Sort Method, default is `helpful`, checkout the table below for possible values', | ||
lang: 'Language, checkout the table below for possible values, default is `en_US`', | ||
}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.taptap.io/app/:id/review', 'www.taptap.io/app/:id'], | ||
target: '/intl/review/:id', | ||
}, | ||
], | ||
name: 'Ratings & Reviews', | ||
maintainers: ['hoilc', 'TonyRL', 'ETiV'], | ||
handler, | ||
description: `Sort Method | ||
| Most Helpful | Most Recent | | ||
| ------------ | ----------- | | ||
| helpful | recent | | ||
Language Code | ||
| English (US) | 繁體中文 | 한국어 | 日本語 | | ||
| ------------ | -------- | ------ | ------ | | ||
| en_US | zh_TW | ko_KR | ja_JP |`, | ||
}; |
Oops, something went wrong.