Skip to content

Commit

Permalink
feat(route): 增加了六个美国博物馆的展讯 (#9451)
Browse files Browse the repository at this point in the history
* Add New York Museums with working code

* Add Guggenheim and fix Jewish Museum

* Add pubDate for Gugg and Met Exhibitions

* Update docs

* Add New Museum and MCA Chicago, update document

* Fix en route

* Add and update radar.js

* Add Brooklyn Museum

* Reformat code

* Update route and travel information

* Fix `http` -> `https` for `radar.js`

* Change some link quotations mark

* Using `parseDate` provided by the project

* Removing "insecureHTTPParser"

* Fix JewishMuseum issue

* Use regex instead of node's vm

* Update lib/v2/jewishmuseum/exhibitions.js

Co-authored-by: Tony <[email protected]>

* Update lib/v2/guggenheim/exhibitions.js

Co-authored-by: Tony <[email protected]>

* Update docs/en/travel.md

Co-authored-by: Tony <[email protected]>

* Update docs/travel.md

Co-authored-by: Tony <[email protected]>

Co-authored-by: Tony <[email protected]>
  • Loading branch information
chazeon and TonyRL authored Apr 4, 2022
1 parent 19608ab commit b17eaf9
Show file tree
Hide file tree
Showing 26 changed files with 313 additions and 0 deletions.
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`']" anticrawler="1"
/>
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`']" anticrawler="1"
/>

## 纽约古根海姆基金会

<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/';
break;
default:
link = `https://www.brooklynmuseum.org/exhibitions/${state}`;
}

ctx.state.data = await buildData({
link,
url: link,
title: 'Brooklyn Museum - Exhibitions',
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: 'https://docs.rsshub.app/en/travel.html#brooklyn-museum',
},
],
},
};
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'));
};
29 changes: 29 additions & 0 deletions lib/v2/guggenheim/exhibitions.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 { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const link = 'https://www.guggenheim.org/exhibitions';

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

const code = cheerio.load(response.data)('#app-js-extra').html();
const data = JSON.parse(code.match(/var bootstrap = ([^\n]*);/)[1]);
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',
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.month} ${ex.dates.start.day}, ${ex.dates.start.year}`, 'MMMM D, YYYY') : null,
})),
};
};
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: 'https://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';

ctx.state.data = await buildData({
link,
url: link,
title: 'Jewish Museums - Exhibitions',
item: {
item: '#current article.exhibition, #upcoming article, #past article.exhibition',
title: `$('article.exhibition h3').text()`,
link: `$('article.exhibition > a').attr('href')`,
},
});
};
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: 'https://docs.rsshub.app/en/travel.html#the-jewish-museum',
},
],
},
};
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';

ctx.state.data = await buildData({
link,
url: link,
title: 'MCA Chicago - Exhibitions',
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: 'https://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');
const { parseDate } = require('@/utils/parse-date');

function generateExhibitionItem(result) {
return {
title: result.title,
link: `https://www.metmuseum.org${result.url}`,
description: result.description,
pubDate: parseDate(result.startDate),
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',
});

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: 'https://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/';
break;
default:
link = `https://www.newmuseum.org/exhibitions/${state}`;
}

ctx.state.data = await buildData({
link,
url: link,
title: 'New Museum - Exhibitions',
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: 'https://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'));
};

0 comments on commit b17eaf9

Please sign in to comment.