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

feat(route): 增加了六个美国博物馆的展讯 #9451

Merged
merged 20 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from 10 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
32 changes: 32 additions & 0 deletions docs/en/travel.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ If the city name contains a space like `Mexico City`, replace the space with `%2

</RouteEn>

## Brooklyn Museum

<RouteEn author="chazeon"
example="/brooklynmuseum/exhibitions"
path="/brooklynmuseum/exhibitions/:state?"
:paramsDesc="['state of the exhibition: `current`,`past`, or `upcoming`, the default value is `current`']"
/>

## Hopper

### Flight Deals
Expand All @@ -31,3 +39,27 @@ This route returns a list of flight deals (in most cases, 6 flight deals) for a
For airport IATA code please refer to [Wikipedia List of airports by IATA code](https://en.wikipedia.org/wiki/List_of_airports_by_IATA_code:_A)

</RouteEn>

## Museum of Contemporary Art Chicago

<RouteEn author="chazeon" example="/mcachicago/exhibitions" path="/mcachicago/exhibitions" />

## New Museum

<RouteEn author="chazeon" example="/newmuseum/exhibitions" path="/newmuseum/exhibitions" />

## Solomon R. Guggenheim Museum

<RouteEn author="chazeon" example="/guggenheim/exhibitions" path="/guggenheim/exhibitions" />

## The Jewish Museum

<RouteEn author="chazeon" example="/jewishmuseum/exhibitions" path="/jewishmuseum/exhibitions" />

## The Metropolitan Museum of Art

<RouteEn author="chazeon"
example="/metmuseum/exhibitions"
path="/metmusem/exhibitions/:state?"
:paramsDesc="['state of the exhibition: `current`,`past`, or `upcoming`, the default value is `current`']"
chazeon marked this conversation as resolved.
Show resolved Hide resolved
/>
32 changes: 32 additions & 0 deletions docs/travel.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,38 @@ IATA 国际航空运输协会机场代码,参见[维基百科 国际航空运

</Route>

## 纽约布鲁克林博物馆

<Route author="chazeon"
example="/brooklynmuseum/exhibitions"
path="/brooklynmuseum/exhibitions/:state?"
:paramsDesc="['展览进行的状态:`current` 对应展览当前正在进行,`past` 对应过去的展览,`upcoming` 对应即将举办的展览,默认为 `current`']"
/>

## 纽约大都会美术馆

<Route author="chazeon"
example="/metmuseum/exhibitions"
path="/metmusem/exhibitions/:state?"
:paramsDesc="['展览进行的状态:`current` 对应展览当前正在进行,`past` 对应过去的展览,`upcoming` 对应即将举办的展览,默认为 `current`']"
chazeon marked this conversation as resolved.
Show resolved Hide resolved
/>

## 纽约古根海姆基金会

<Route author="chazeon" example="/guggenheim/exhibitions" path="/guggenheim/exhibitions" />

## 纽约新美术馆

<Route author="chazeon" example="/newmuseum/exhibitions" path="/newmuseum/exhibitions" />

## 纽约犹太人博物馆

<Route author="chazeon" example="/jewishmuseum/exhibitions" path="/jewishmuseum/exhibitions" />

## 芝加哥当代艺术博物馆

<Route author="chazeon" example="/mcachicago/exhibitions" path="/mcachicago/exhibitions" />

## 中国美术馆

### 美术馆新闻
Expand Down
27 changes: 27 additions & 0 deletions lib/v2/brooklynmuseum/exhibitions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const buildData = require('@/utils/common-config');

module.exports = async (ctx) => {
let link;
const state = ctx.params.state;

switch (state) {
case undefined:
case 'current':
link = `https://www.brooklynmuseum.org/exhibitions/`;
chazeon marked this conversation as resolved.
Show resolved Hide resolved
break;
default:
link = `https://www.brooklynmuseum.org/exhibitions/${state}`;
}

ctx.state.data = await buildData({
link,
url: link,
title: `Brooklyn Museum - Exhibitions`,
chazeon marked this conversation as resolved.
Show resolved Hide resolved
item: {
item: '.exhibitions .image-card',
title: `$('h2 > a, h3 > a').text()`,
link: `$('h2 > a, h3 > a').attr('href')`,
description: `$('h6').text()`,
},
});
};
3 changes: 3 additions & 0 deletions lib/v2/brooklynmuseum/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/exhibitions': ['chazeon'],
};
11 changes: 11 additions & 0 deletions lib/v2/brooklynmuseum/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
'brooklynmuseum.org': {
_name: 'Brooklyn Museum',
www: [
{
title: 'Exhibitions',
docs: 'http://docs.rsshub.app/en/travel.html#brooklyn-museum',
chazeon marked this conversation as resolved.
Show resolved Hide resolved
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/brooklynmuseum/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/exhibitions/:state?', require('./exhibitions'));
};
35 changes: 35 additions & 0 deletions lib/v2/guggenheim/exhibitions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const vm = require('vm');

function parseDate(dateObj) {
return Date.parse(`${dateObj.month} ${dateObj.day}, ${dateObj.year}`);
}
chazeon marked this conversation as resolved.
Show resolved Hide resolved

module.exports = async (ctx) => {
const link = `https://www.guggenheim.org/exhibitions`;
chazeon marked this conversation as resolved.
Show resolved Hide resolved

const response = await got({
url: link,
method: 'GET',
});

const code = cheerio.load(response.data)('#app-js-extra').html();
const context = vm.createContext();
vm.runInContext(code, context);
const data = context.bootstrap;
chazeon marked this conversation as resolved.
Show resolved Hide resolved
const exhibitions = data.initial.main.posts.featuredExhibitions;
const items = [].concat(exhibitions.past.items ?? [], exhibitions.on_view.items ?? [], exhibitions.upcoming.items ?? []);

ctx.state.data = {
link,
url: link,
title: `The Guggenheim Museums and Foundation - Exhibitions`,
chazeon marked this conversation as resolved.
Show resolved Hide resolved
item: items.map((ex) => ({
title: ex.title,
link: `https://www.guggenheim.org/exhibition/${ex.slug}`,
description: ex.excerpt,
pubDate: ex.dates ? parseDate(ex.dates.start) : null,
chazeon marked this conversation as resolved.
Show resolved Hide resolved
})),
};
};
3 changes: 3 additions & 0 deletions lib/v2/guggenheim/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/exhibitions': ['chazeon'],
};
11 changes: 11 additions & 0 deletions lib/v2/guggenheim/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
'guggenheim.org': {
_name: 'Solomon R. Guggenheim Museum',
www: [
{
title: 'Exhibitions',
docs: 'http://docs.rsshub.app/en/travel.html#solomon-r-guggenheim-museum',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/guggenheim/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/exhibitions', require('./exhibitions'));
};
16 changes: 16 additions & 0 deletions lib/v2/jewishmuseum/exhibitions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const buildData = require('@/utils/common-config');

module.exports = async (ctx) => {
const link = `https://thejewishmuseum.org/exhibitions`;
chazeon marked this conversation as resolved.
Show resolved Hide resolved

ctx.state.data = await buildData({
link,
url: link,
title: `Jewish Museums - Exhibitions`,
chazeon marked this conversation as resolved.
Show resolved Hide resolved
item: {
item: 'article',
title: `$('article.exhibition h3').text()`,
link: `$('article.exhibition > a').attr('href')`,
},
});
};
TonyRL marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions lib/v2/jewishmuseum/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/exhibitions': ['chazeon'],
};
11 changes: 11 additions & 0 deletions lib/v2/jewishmuseum/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
'thejewishmuseum.org': {
_name: 'Jewish Museum',
'.': [
{
title: 'Exhibitions',
docs: 'http://docs.rsshub.app/en/travel.html#the-jewish-museum',
chazeon marked this conversation as resolved.
Show resolved Hide resolved
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/jewishmuseum/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/exhibitions', require('./exhibitions'));
};
17 changes: 17 additions & 0 deletions lib/v2/mcachicago/exhibitions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const buildData = require('@/utils/common-config');

module.exports = async (ctx) => {
const link = `https://mcachicago.org/exhibitions`;
chazeon marked this conversation as resolved.
Show resolved Hide resolved

ctx.state.data = await buildData({
link,
url: link,
title: `MCA Chicago - Exhibitions`,
chazeon marked this conversation as resolved.
Show resolved Hide resolved
item: {
item: '#exhibitions .card',
title: `$('.title').text()`,
link: `$('a').attr('href')`,
// description: `$('a').html()`,
},
});
};
3 changes: 3 additions & 0 deletions lib/v2/mcachicago/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/exhibitions': ['chazeon'],
};
11 changes: 11 additions & 0 deletions lib/v2/mcachicago/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
'mcachicago.org': {
_name: 'MCA Chicago',
'.': [
{
title: 'Exhibitions',
docs: 'http://docs.rsshub.app/en/travel.html#museum-of-contemporary-art-chicago',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/mcachicago/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/exhibitions', require('./exhibitions'));
};
31 changes: 31 additions & 0 deletions lib/v2/metmuseum/exhibitions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const got = require('@/utils/got');

function generateExhibitionItem(result) {
return {
title: result.title,
link: `https://www.metmuseum.org${result.url}`,
description: result.description,
pubDate: result.startDate,
chazeon marked this conversation as resolved.
Show resolved Hide resolved
guid: result.id,
};
}

module.exports = async (ctx) => {
const searchType = ctx.params.state ?? 'current';

const url = `https://www.metmuseum.org/ghidorah/ExhibitionListing/Search?searchType=${searchType}`;

const response = await got({
url,
method: 'GET',
insecureHTTPParser: true,
TonyRL marked this conversation as resolved.
Show resolved Hide resolved
});

const data = response.data.data;

ctx.state.data = {
title: 'The Metropolitan Museum of Art - Exhibitions',
link: 'https://www.metmuseum.org/exhibitions',
item: data.results.map(generateExhibitionItem),
};
};
3 changes: 3 additions & 0 deletions lib/v2/metmuseum/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/exhibitions': ['chazeon'],
};
11 changes: 11 additions & 0 deletions lib/v2/metmuseum/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
'metmuseum.org': {
_name: 'The Metropolitan Museum of Art',
www: [
{
title: 'Exhibitions',
docs: 'http://docs.rsshub.app/en/travel.html#the-metropolitan-museum-of-art',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/metmuseum/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/exhibitions/:state?', require('./exhibitions'));
};
27 changes: 27 additions & 0 deletions lib/v2/newmuseum/exhibitions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const buildData = require('@/utils/common-config');

module.exports = async (ctx) => {
let link;
const state = ctx.query.state;

switch (state) {
case undefined:
case 'current':
link = `https://www.newmuseum.org/exhibitions/`;
chazeon marked this conversation as resolved.
Show resolved Hide resolved
break;
default:
link = `https://www.newmuseum.org/exhibitions/${state}`;
}

ctx.state.data = await buildData({
link,
url: link,
title: `New Museum - Exhibitions`,
chazeon marked this conversation as resolved.
Show resolved Hide resolved
item: {
item: '.exh',
title: `$('.exh .title').text()`,
link: `$('.exh > a').attr('href')`,
description: `$('.exh .body-reveal').text()`,
},
});
};
3 changes: 3 additions & 0 deletions lib/v2/newmuseum/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/exhibitions': ['chazeon'],
};
11 changes: 11 additions & 0 deletions lib/v2/newmuseum/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
'newmuseum.org': {
_name: 'New Museum',
www: [
{
title: 'Exhibitions',
docs: 'http://docs.rsshub.app/en/travel.html#new-museum',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/newmuseum/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/exhibitions', require('./exhibitions'));
};