Skip to content
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

[pull] master from diygod:master #824

Merged
merged 4 commits into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/en/journal.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ See [Browse Content](https://pubs.acs.org)

</RouteEn>

## Annual Reviews

### Journal

<RouteEn author="nczitzk" example="/annualreviews/anchem" path="/annualreviews/:id" :paramsDesc="['Journal id, can be found in URL']" supportScihub="1">

The URL of the journal [Annual Review of Analytical Chemistry](https://www.annualreviews.org/journal/anchem) is `https://www.annualreviews.org/journal/anchem`, where `anchem` is the id of the journal, so the route for this journal is `/annualreviews/anchem`.

::: tip Tip

More jounals can be found in [Browse Journals](https://www.annualreviews.org/action/showPublications).

:::

</RouteEn>

## arXiv

### Search Keyword
Expand Down
16 changes: 16 additions & 0 deletions docs/journal.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ pageClass: routes

</Route>

## Annual Reviews

### Journal

<Route author="nczitzk" example="/annualreviews/anchem" path="/annualreviews/:id" :paramsDesc="['期刊 id,可在对应期刊页 URL 中找到']" supportScihub="1">

期刊 [Annual Review of Analytical Chemistry](https://www.annualreviews.org/journal/anchem) 的 URL 是 `https://www.annualreviews.org/journal/anchem`,其中 `anchem` 即为其期刊 id,故该期刊对应路由为 `/annualreviews/anchem`。

::: tip 提示

更多期刊可在 [Browse Journals](https://www.annualreviews.org/action/showPublications) 中找到。

:::

</Route>

## arXiv

### 搜索关键字
Expand Down
38 changes: 38 additions & 0 deletions docs/new-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,44 @@ pageClass: routes

<Route author="nczitzk" example="/dayone/blog" path="/dayone/blog"/>

## DCFever

### 新聞中心

<Route author="TonyRL" example="/dcfever/news" path="/dcfever/news/:type?" :paramsDesc="['分類,預設為所有新聞']" radar="1">

| 所有新聞 | 攝影器材 | 手機通訊 | 汽車熱話 | 攝影文化 | 影片攝錄 | 測試報告 | 生活科技 | 攝影技巧 |
| ---- | ------ | ------ | ---- | ----------- | ----------- | ------- | ------ | --------- |
| | camera | mobile | auto | photography | videography | reviews | gadget | technique |

</Route>

### 測試報告

<Route author="TonyRL" example="/dcfever/reviews/cameras" path="/dcfever/reviews/:type?" :paramsDesc="['分類,預設為 `cameras`']" radar="1">

| 相機及鏡頭 | 手機平板 | 試車報告 |
| ------- | ------ | ---- |
| cameras | phones | cars |

</Route>

### 二手市集

<Route author="TonyRL" example="/dcfever/trading/1" path="/dcfever/trading/:id" :paramsDesc="['分類 ID,見下表']" radar="1">

[所有物品分類](https://www.dcfever.com/trading/index.php#all_cats)

| 攝影產品 | 電腦 | 手機通訊 | 影音產品 | 遊戲機、模型 | 電器傢俱 | 潮流服飾 | 手錶 | 單車及運動 | 其它 |
| ---- | -- | ---- | ---- | ------ | ---- | ---- | -- | ----- | -- |
| 1 | 2 | 3 | 44 | 43 | 104 | 45 | 99 | 109 | 4 |

</Route>

### 二手市集 - 物品搜尋

<Route author="TonyRL" example="/dcfever/trading/search/Sony" path="/dcfever/trading/search/:keyword/:mainCat?" :paramsDesc="['關鍵字', '主要分類 ID,見上表']" radar="1" />

## DeepL

### Blog
Expand Down
68 changes: 68 additions & 0 deletions lib/v2/annualreviews/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const id = ctx.params.id;

const rootUrl = 'https://www.annualreviews.org';
const apiRootUrl = `https://api.crossref.org`;
const feedUrl = `${rootUrl}/r/${id}_rss`;
const currentUrl = `${rootUrl}/toc/${id}/current`;

const response = await got({
method: 'get',
url: feedUrl,
});

const $ = cheerio.load(response.data);

let items = $('entry')
.toArray()
.map((item) => {
item = $(item);

const doi = item.find('id').text().split('doi=').pop();

return {
doi,
guid: doi,
title: item.find('title').text(),
link: item.find('link').attr('href').split('?')[0],
description: item.find('content').text(),
pubDate: parseDate(item.find('published').text()),
author: item
.find('author name')
.toArray()
.map((a) => $(a).text())
.join(', '),
};
});

items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.guid, async () => {
const apiUrl = `${apiRootUrl}/works/${item.doi}`;

const detailResponse = await got({
method: 'get',
url: apiUrl,
});

item.description = detailResponse.data.message.abstract.replace(/jats:p>/g, 'p>');

return item;
})
)
);

ctx.state.data = {
title: $('title')
.first()
.text()
.replace(/: Table of Contents/, ''),
description: $('subtitle').first().text(),
link: currentUrl,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/annualreviews/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:id': ['nczitzk'],
};
13 changes: 13 additions & 0 deletions lib/v2/annualreviews/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'annualreviews.org': {
_name: 'Annual Reviews',
'.': [
{
title: 'Journal',
docs: 'https://docs.rsshub.app/journal.html#annual-reviews-journal',
source: ['/journal/:id', '/'],
target: '/annualreviews/:id',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/annualreviews/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:id', require('./index'));
};
6 changes: 6 additions & 0 deletions lib/v2/dcfever/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
'/news/:type?': ['TonyRL'],
'/reviews/:type?': ['TonyRL'],
'/trading/search/:keyword/:mainCat?': ['TonyRL'],
'/trading/:id': ['TonyRL'],
};
36 changes: 36 additions & 0 deletions lib/v2/dcfever/news.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { baseUrl, parseItem } = require('./utils');

module.exports = async (ctx) => {
const { type } = ctx.params;

const response = await got(`${baseUrl}/news/index.php`, {
searchParams: {
type: type ? type : undefined,
},
});
const $ = cheerio.load(response.data);

const list = $('.col-md-left .title a')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: new URL(item.attr('href'), response.url).href,
};
});

const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));

ctx.state.data = {
title: `${$('.channel_nav')
.contents()
.filter((_, e) => e.nodeType === 3)
.text()} - ${$('head title').text()}`,
link: response.url,
image: 'https://cdn10.dcfever.com/images/android_192.png',
item: items,
};
};
37 changes: 37 additions & 0 deletions lib/v2/dcfever/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
'dcfever.com': {
_name: 'DCFever',
'.': [
{
title: '新聞中心',
docs: 'https://docs.rsshub.app/new-media.html#dcfever',
source: ['/news/index.php', '/'],
params: (_, url) => {
const searchParams = new URL(url).searchParams;
return `/dcfever/news${searchParams.has('type') ? `/${new URL(url).searchParams.get('type')}` : ''}`;
},
},
{
title: '測試報告',
docs: 'https://docs.rsshub.app/new-media.html#dcfever',
source: ['/:type/reviews.php'],
params: '/dcfever/reviews/:type',
},
{
title: '二手市集',
docs: 'https://docs.rsshub.app/new-media.html#dcfever',
source: ['/trading/listing.php'],
params: (_, url) => `/dcfever/trading/${new URL(url).searchParams.get('id')}`,
},
{
title: '二手市集 - 物品搜尋',
docs: 'https://docs.rsshub.app/new-media.html#dcfever',
source: ['/trading/search.php'],
params: (_, url) => {
const searchParams = new URL(url).searchParams;
return `/dcfever/trading/search/${searchParams.get('keyword')}${searchParams.has('main_cat') ? `/${searchParams.get('main_cat')}` : ''}`;
},
},
],
},
};
29 changes: 29 additions & 0 deletions lib/v2/dcfever/reviews.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { baseUrl, parseItem } = require('./utils');

module.exports = async (ctx) => {
const { type = 'cameras' } = ctx.params;

const response = await got(`${baseUrl}/${type}/reviews.php`);
const $ = cheerio.load(response.data);

const list = $('.col-md-left .title a')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: new URL(item.attr('href'), response.url).href,
};
});

const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));

ctx.state.data = {
title: $('head title').text(),
link: response.url,
image: 'https://cdn10.dcfever.com/images/android_192.png',
item: items,
};
};
6 changes: 6 additions & 0 deletions lib/v2/dcfever/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = (router) => {
router.get('/news/:type?', require('./news'));
router.get('/reviews/:type?', require('./reviews'));
router.get('/trading/search/:keyword/:mainCat?', require('./trading-search'));
router.get('/trading/:id', require('./trading'));
};
14 changes: 14 additions & 0 deletions lib/v2/dcfever/templates/trading.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<h2>{{ info.find('.trading_item_title').text() }}</h2>
{{ info.find('.trading_item_type_tag').text() }} {{ info.find('.trading_item_price').text() }}<br>
<table>
<tr><th>賣家</th><td>{{ info.find('.clearfix .content').eq(0).text() }}</td></tr>
<tr><th>查詢次數</th><td>{{ info.find('.clearfix .content').eq(1).text() }}</td></tr>
<tr><th>瀏覽次數</th><td>{{ info.find('.clearfix .content').eq(2).text() }}</td></tr>
<tr><th>刊登日期</th><td>{{ info.find('.clearfix .content').eq(3).text() }}</td></tr>
<tr><th>最後更新</th><td>{{ info.find('.clearfix .content').eq(4).text() }}</td></tr>
<tr><th>刊登期至</th><td>{{ info.find('.clearfix .content').eq(5).text() }}</td></tr>
<tr><th>刊登狀態</th><td>{{ info.find('.clearfix .content').eq(6).text() }}</td></tr>
</table><br>

{{@ description }}<br><br>
{{@ photo }}
39 changes: 39 additions & 0 deletions lib/v2/dcfever/trading-search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
// const { parseRelativeDate } = require('@/utils/parse-date');
const { baseUrl, parseTradeItem } = require('./utils');

module.exports = async (ctx) => {
const { keyword, mainCat } = ctx.params;

const response = await got(`${baseUrl}/trading/search.php`, {
searchParams: {
keyword,
type: 'all',
main_cat: mainCat,
form_action: 'search_action',
},
});
const $ = cheerio.load(response.data);

const list = $('.item_list li a')
.toArray()
.map((item) => {
item = $(item);
item.find('.optional').remove();
return {
title: item.find('.trade_title').text(),
link: new URL(item.attr('href'), response.url).href,
author: item.find('.trade_info').text(),
};
});

const items = await Promise.all(list.map((item) => parseTradeItem(item, ctx.cache.tryGet)));

ctx.state.data = {
title: $('head title').text(),
link: response.url,
image: 'https://cdn10.dcfever.com/images/android_192.png',
item: items,
};
};
39 changes: 39 additions & 0 deletions lib/v2/dcfever/trading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
// const { parseRelativeDate } = require('@/utils/parse-date');
const { baseUrl, parseTradeItem } = require('./utils');

module.exports = async (ctx) => {
const { id, order = 'new' } = ctx.params;

const response = await got(`${baseUrl}/trading/listing.php`, {
searchParams: {
id,
order,
type: 'all',
},
});
const $ = cheerio.load(response.data);

const list = $('.item_list li a')
.toArray()
.filter((item) => $(item).attr('href') !== '/documents/advertising.php')
.map((item) => {
item = $(item);
item.find('.optional').remove();
return {
title: item.find('.trade_title').text(),
link: new URL(item.attr('href'), response.url).href,
author: item.find('.trade_info').text(),
};
});

const items = await Promise.all(list.map((item) => parseTradeItem(item, ctx.cache.tryGet)));

ctx.state.data = {
title: $('head title').text(),
link: response.url,
image: 'https://cdn10.dcfever.com/images/android_192.png',
item: items,
};
};
Loading