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.
Merge pull request #1366 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
10 changed files
with
225 additions
and
45 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
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,67 @@ | ||
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'; | ||
|
||
const type = (filename) => filename.split('.').pop(); | ||
|
||
export const route: Route = { | ||
path: '/jwc', | ||
categories: ['university'], | ||
example: '/ecnu/jwc', | ||
radar: [ | ||
{ | ||
source: ['www.jwc.ecnu.edu.cn', 'www.ecnu.edu.cn'], | ||
target: '/tzgg', | ||
}, | ||
], | ||
name: '教务处通知', | ||
maintainers: ['markbang'], | ||
handler: async () => { | ||
const baseUrl = 'http://www.jwc.ecnu.edu.cn/'; | ||
|
||
const response = await got(`${baseUrl}tzggwwxsgg/list.htm`); | ||
const $ = load(response.data); | ||
const links = $('.col_news_con ul.news_list > li') | ||
.map((_, el) => ({ | ||
pubDate: timezone(parseDate($(el).find('.news_date').text()), 8), | ||
link: new URL($(el).find('a').attr('href'), baseUrl).toString(), | ||
title: $(el).find('a').text(), | ||
})) | ||
.get(); | ||
const items = await Promise.all( | ||
links.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
if (type(item.link) === 'htm') { | ||
try { | ||
const { data } = await got(item.link, { | ||
https: { | ||
rejectUnauthorized: false, | ||
}, | ||
}); | ||
const $ = load(data); | ||
item.description = $('div.article')?.html()?.replaceAll('src="/', `src="${baseUrl}/`)?.replaceAll('href="/', `href="${baseUrl}/`)?.trim(); | ||
return item; | ||
} catch { | ||
// intranet | ||
item.description = '请进行统一身份认证之后再访问'; | ||
return item; | ||
} | ||
} else { | ||
// file to download | ||
item.description = '点击认证后访问内容'; | ||
return item; | ||
} | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: '教务处通知', | ||
link: 'http://www.jwc.ecnu.edu.cn/tzggwwxsgg/list.htm', | ||
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,92 @@ | ||
import { Route } from '@/types'; | ||
import { getCurrentPath } from '@/utils/helpers'; | ||
const __dirname = getCurrentPath(import.meta.url); | ||
|
||
import ofetch from '@/utils/ofetch'; | ||
import { art } from '@/utils/render'; | ||
import path from 'node:path'; | ||
|
||
const workshopFileTypes = { | ||
0: 'Community', | ||
1: 'Microtransaction', | ||
2: 'Collection', | ||
3: 'Art', | ||
4: 'Video', | ||
5: 'Screenshot', | ||
6: 'Game', | ||
7: 'Software', | ||
8: 'Concept', | ||
9: 'WebGuide', | ||
10: 'IntegratedGuide', | ||
11: 'Merch', | ||
12: 'ControllerBinding', | ||
13: 'SteamworksAccessInvite', | ||
14: 'SteamVideo', | ||
15: 'GameManagedItem', | ||
}; | ||
|
||
export const route: Route = { | ||
path: '/appcommunityfeed/:appid/:routeParams?', | ||
categories: ['game'], | ||
example: '/steam/appcommunityfeed/730', | ||
parameters: { | ||
appid: 'Steam appid, can be found on the community hub page or store page URL.', | ||
routeParams: 'Query parameters.', | ||
}, | ||
radar: [ | ||
{ | ||
title: 'Community Hub', | ||
source: ['steamcommunity.com/app/:appid'], | ||
target: '/appcommunityfeed/:appid', | ||
}, | ||
{ | ||
title: 'Community Hub', | ||
source: ['store.steampowered.com/app/:appid/*/'], | ||
target: '/appcommunityfeed/:appid', | ||
}, | ||
], | ||
description: `Query Parameters: | ||
| Name | Type | Description | | ||
| ---------------------- | ------ | ----------------------- | | ||
| p | string | p | | ||
| rgSections[] | string | rgSections | | ||
| filterLanguage | string | Filter Language | | ||
| languageTag | string | Language Tag | | ||
| nMaxInappropriateScore | string | Max Inappropriate Score | | ||
Example: | ||
- \`/appcommunityfeed/730/p=1&rgSections[]=2&rgSections[]=4&filterLanguage=english&languageTag=english&nMaxInappropriateScore=1\` for CS2 Screenshot and Artwork contents. | ||
- \`/appcommunityfeed/730/rgSections[]=6\` for CS2 Workshop contents only. | ||
- \`/appcommunityfeed/570/rgSections[]=3&rgSections[]=9\` for Dota2 Video and Guides contents. | ||
:::tip | ||
It can also access community hub contents that require a logged-in account. | ||
::: | ||
`, | ||
name: 'Steam Community Hub Feeds', | ||
maintainers: ['NyaaaDoge'], | ||
|
||
handler: async (ctx) => { | ||
const { appid = 730, routeParams } = ctx.req.param(); | ||
|
||
const baseUrl = 'https://steamcommunity.com'; | ||
const apiUrl = `${baseUrl}/library/appcommunityfeed/${appid}${routeParams ? `?${routeParams}` : ''}`; | ||
const response = await ofetch(apiUrl); | ||
|
||
return { | ||
title: `${appid} Steam Community Hub`, | ||
link: `https://steamcommunity.com/app/${appid}`, | ||
item: response.hub.map((item) => ({ | ||
title: item.title === '' ? workshopFileTypes[item.type] : item.title, | ||
link: `https://steamcommunity.com/sharedfiles/filedetails/?id=${item.published_file_id}`, | ||
description: art(path.join(__dirname, 'templates/appcommunityfeed-description.art'), { | ||
image: item.full_image_url, | ||
description: item.description, | ||
}), | ||
author: item.creator.name, | ||
category: workshopFileTypes[item.type], | ||
})), | ||
}; | ||
}, | ||
}; |
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,4 @@ | ||
{{ if image }} | ||
<img src="{{ image }}"/> | ||
{{ /if }} | ||
<p>{{ description }}</p> |
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
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
Oops, something went wrong.