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 #53 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
16 changed files
with
378 additions
and
53 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import got from '@/utils/got'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
|
||
export const route: Route = { | ||
path: '/:city/:pollution?', | ||
categories: ['other'], | ||
example: '/aqicn/beijing/pm25', | ||
parameters: { | ||
city: '城市拼音或地区 ID,详见[aqicn.org](http://aqicn.org/city/)', | ||
pollution: '可选择显示更详细的空气污染成分', | ||
}, | ||
radar: [ | ||
{ | ||
source: ['aqicn.org'], | ||
}, | ||
], | ||
name: '实时 AQI', | ||
maintainers: ['ladeng07'], | ||
handler, | ||
url: 'aqicn.org', | ||
descriptions: ` | ||
| 参数 | 污染成分 | | ||
| -------- | -------- | | ||
| pm25 | PM2.5 | | ||
| pm10 | PM10 | | ||
| o3 | O3 | | ||
| no2 | NO2 | | ||
| so2 | SO2 | | ||
| co | CO | | ||
举例: [https://rsshub.app/aqicn/beijing/pm25,pm10](https://rsshub.app/aqicn/beijing/pm25,pm10) | ||
1. 显示单个污染成分,例如「pm25」, [https://rsshub.app/aqicn/beijing/pm25](https://rsshub.app/aqicn/beijing/pm25) | ||
2. 逗号分隔显示多个污染成分,例如「pm25,pm10」,[https://rsshub.app/aqicn/beijing/pm25,pm10](https://rsshub.app/aqicn/beijing/pm25,pm10) | ||
3. 城市子站 ID 获取方法:右键显示网页源代码,搜索 "idx" (带双冒号),后面的 ID 就是子站的 ID,如你给的链接 ID 是 4258,RSS 地址就是 [https://rsshub.app/aqicn/4258](https://rsshub.app/aqicn/4258) | ||
`, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const city = ctx.req.param('city'); | ||
const pollution = ctx.req.param('pollution') || []; | ||
const pollutionType = { | ||
so2: 'so2', | ||
no2: 'no2', | ||
co: 'co', | ||
o3: 'O3', | ||
pm25: 'PM2.5', | ||
pm10: 'PM10', | ||
}; | ||
const area = Number.isNaN(Number(city)) ? city : `@${city}`; | ||
|
||
const response = await got({ | ||
method: 'get', | ||
url: `http://aqicn.org/aqicn/json/android/${area}/json`, | ||
}); | ||
const data = response.data; | ||
const pollutionDetailed = | ||
pollution.length === 0 | ||
? '' | ||
: pollution | ||
.split(',') | ||
.map((item) => { | ||
const pollutionValue = typeof data.historic[pollutionType[item]] === 'object' ? data.historic[pollutionType[item]][Object.keys(data.historic[pollutionType[item]])[0]] : data.historic[pollutionType[item]][0]; | ||
return `${pollutionType[item].toUpperCase()}:<b>${pollutionValue}</b><br>`; | ||
}) | ||
.join(''); | ||
|
||
return { | ||
title: `${data.namena}AQI`, | ||
link: `https://aqicn.org/city/${data.ids.path}`, | ||
description: `${data.namena}AQI-aqicn.org`, | ||
item: [ | ||
{ | ||
title: `${data.namena}实时空气质量(AQI)${data.utimecn}`, | ||
description: `${data.infocn}<br>风力:<b>${data.cwind[0]}</b>级<br>AQI:<b>${data.aqi}</b><br>${pollutionDetailed}<img src="${data.wgt}">`, | ||
pubDate: parseDate(data.time * 1000), | ||
guid: `${data.time}-${city}-${pollution}`, | ||
link: `https://aqicn.org/city/${data.ids.path}`, | ||
}, | ||
], | ||
}; | ||
} |
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,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: '空气质量', | ||
url: 'aqicn.org', | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { DataItem, Route } from '@/types'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
const url = 'https://censorbib.nymity.ch/'; | ||
|
||
export const route: Route = { | ||
path: '/censorbib', | ||
categories: ['journal'], | ||
example: '/nymity/censorbib', | ||
radar: [ | ||
{ | ||
source: ['censorbib.nymity.ch/'], | ||
}, | ||
], | ||
name: 'CensorBib Updates', | ||
maintainers: ['xtexChooser'], | ||
handler, | ||
url: 'censorbib.nymity.ch/', | ||
}; | ||
|
||
async function handler() { | ||
const resp = await got.get(url); | ||
|
||
const $ = load(resp.data); | ||
const items = $('#container ul li') | ||
.toArray() | ||
.map((item): DataItem => { | ||
const c = $(item); | ||
const id = c.attr('id')!; | ||
const title = c.find('span.paper').text().trim(); | ||
const author = c.find('span.author').text().trim(); | ||
const other = c.find('span.other').text().trim(); | ||
const download = c.find("img.icon[title='Download paper']").parent().attr('href'); | ||
const downloadBibTex = c.find("img.icon[title='Download BibTeX']").parent().attr('href'); | ||
const linkToPaper = c.find("img.icon[title='Link to paper']").parent().attr('href'); | ||
return { | ||
title, | ||
description: `${other}<br/><br/><a href='${download}'>Download</a><br/><a href='${downloadBibTex}'>Download BibTex</a>`, | ||
author, | ||
guid: id, | ||
link: linkToPaper, | ||
}; | ||
}); | ||
|
||
return { | ||
title: 'CensorBib', | ||
link: url, | ||
description: 'CensorBib Updates', | ||
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,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'nymity', | ||
url: 'censorbib.nymity.ch', | ||
}; |
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.