-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(route/nintendo): Add 任天堂官网 #17255
Open
benzking
wants to merge
11
commits into
DIYgod:master
Choose a base branch
from
benzking:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bf30ddf
feat(route): add route for 任天堂新闻
benzking b616531
fix(route): nintendo.com.hk
benzking 2b0f1f7
fix(route): nintendo.com.jp
benzking dd85a2b
fix(route): nintendo.com.hk
benzking 3eccca8
fix(route): nintendo.com.jp
benzking 3500415
fix(route): nintendo.com.hk
benzking f7469ed
Update news-hk.ts
benzking 290eebc
Update news-hk.ts
benzking ad416b9
Update news-jp.ts
benzking b31824b
Update news-hk.ts
benzking cbd667a
Update news-jp.ts
benzking File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,73 @@ | ||
import { Route } from '@/types'; | ||
import cache from '@/utils/cache'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import timezone from '@/utils/timezone'; | ||
|
||
export const route: Route = { | ||
path: '/news/hk', | ||
categories: ['game'], | ||
example: '/nintendo/news/hk', | ||
parameters: {}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['nintendo.com.hk/topics', 'nintendo.com.hk/'], | ||
}, | ||
], | ||
name: 'News(Hong Kong)', | ||
maintainers: ['benzking'], | ||
handler, | ||
url: 'nintendo.com.hk/topics', | ||
}; | ||
|
||
async function handler(ctx) { | ||
const response = await got('https://www.nintendo.com.hk/api/top/topics_pickup'); | ||
const data = response.data.slice(0, 2); | ||
console.log(data); | ||
|
||
const list = data.map((item) => ({ | ||
// 文章标题 | ||
title: item.title, | ||
// 文章链接 | ||
link: `https://www.nintendo.com.hk${item.href}`, | ||
// 文章发布日期 | ||
pubDate: timezone(parseDate(item.displayDate, 'YYYY.M.D'),+8), | ||
Check failure Code scanning / ESLint Enforce consistent spacing before and after commas Error
A space is required after ','.
|
||
itunes_item_image:item.banner.url, | ||
category:item.category, | ||
})); | ||
console.log(list); | ||
|
||
// 获取新闻正文 | ||
const items = await Promise.all( | ||
list.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
//判断 | ||
|
||
console.log(item.link); | ||
|
||
const { data: response } = await got(item.link); | ||
console.log(data); | ||
|
||
console.log(response); | ||
|
||
const $ = load(response); | ||
// 选择类名为“comment-body”的第一个元素 | ||
item.description = $('div.topics-articleBody').first().html(); | ||
// 上面每个列表项的每个属性都在此重用, | ||
// 并增加了一个新属性“description” | ||
return item; | ||
}) | ||
) | ||
); | ||
|
||
|
||
console.log(items); | ||
|
||
return { | ||
title: 'Nintendo(香港)主页资讯', | ||
link: 'https://www.nintendo.com.hk/topics/', | ||
description: 'Nintendo 香港有限公司官网刊登的资讯', | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Route } from '@/types'; | ||
import cache from '@/utils/cache'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
|
||
export const route: Route = { | ||
path: '/news/jp', | ||
categories: ['game'], | ||
example: '/nintendo/news/jp', | ||
parameters: {}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['nintendo.com/jp'], | ||
}, | ||
], | ||
name: 'News(JP)', | ||
maintainers: ['benzking'], | ||
handler, | ||
url: 'nintendo.com/jp', | ||
}; | ||
|
||
async function handler(ctx) { | ||
Check failure Code scanning / ESLint Disallow unused variables Error
'ctx' is defined but never used.
|
||
const response = await got('https://www.nintendo.com/jp/topics/c/api/json_list?key=newtopics'); | ||
console.log(response); | ||
|
||
const data = response.data.slice(0, 10); | ||
console.log(data); | ||
|
||
const list = data.map((item) => ({ | ||
// 文章标题 | ||
title: item.title, | ||
// 文章链接 | ||
link: item.topic_url, | ||
// 文章发布日期 | ||
pubDate: parseDate(item.release_date, 'YYYY/M/D HH:mm:ss'), // "release_date": "2024/10/18 17:00:00" | ||
itunes_item_image:item.thumbnail.large.medium, | ||
category:item.categorylarge.name, | ||
})); | ||
console.log(list); | ||
|
||
// 获取新闻正文 | ||
const items = await Promise.all( | ||
list.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
const { data: response } = await got(item.link); | ||
const $ = load(response); | ||
// 选择类名为“comment-body”的第一个元素 | ||
item.description = $('div.topics-articleBody').first().html(); | ||
// 上面每个列表项的每个属性都在此重用, | ||
// 并增加了一个新属性“description” | ||
return item; | ||
}) | ||
) | ||
); | ||
console.log(items); | ||
|
||
return { | ||
title: 'Nintendo(日本)主页资讯', | ||
link: 'https://www.nintendo.com/jp/topics', | ||
description: 'Nintendo JP', | ||
item:items, | ||
}; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / ESLint
Disallow unused variables Error