Skip to content

Commit

Permalink
Merge pull request #750 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Jan 24, 2023
2 parents 64f5b3c + 3367005 commit ee813ff
Show file tree
Hide file tree
Showing 16 changed files with 214 additions and 73 deletions.
12 changes: 12 additions & 0 deletions docs/en/game.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,15 @@ News data from https://warthunder.com/en/news/
The year, month and day provided under UTC time zone are the same as the official website, so please ignore the specific time!!!

</RouteEn>

## ファミ通

### Category

<RouteEn author="TonyRL" example="/famitsu/category/new-article" path="/famitsu/category/:category?" :paramsDesc="['Category, see table below, `new-article` by default']" radar="1">

| 新着 | PS5 | Switch | PS4 | ニュース | ゲームニュース | PR TIMES | 動画 | 特集・企画記事 | インタビュー | 取材・リポート | レビュー | インディーゲーム |
| ----------- | --- | ------ | --- | ---- | --------- | -------- | ------ | --------------- | --------- | ------------ | ------ | ---------- |
| new-article | ps5 | switch | ps4 | news | news-game | prtimes | videos | special-article | interview | event-report | review | indie-game |

</RouteEn>
12 changes: 12 additions & 0 deletions docs/game.md
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,18 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`

<Route author="magic-akari" example="/kirara/news" path="/kirara/news"/>

## ファミ通

### 分类

<Route author="TonyRL" example="/famitsu/category/new-article" path="/famitsu/category/:category?" :paramsDesc="['分类,见下表,预设为 `new-article`']" radar="1">

| 新着 | PS5 | Switch | PS4 | ニュース | ゲームニュース | PR TIMES | 動画 | 特集・企画記事 | インタビュー | 取材・リポート | レビュー | インディーゲーム |
| ----------- | --- | ------ | --- | ---- | --------- | -------- | ------ | --------------- | --------- | ------------ | ------ | ---------- |
| new-article | ps5 | switch | ps4 | news | news-game | prtimes | videos | special-article | interview | event-report | review | indie-game |

</Route>

## マギアレコード(Magia Record, 魔法纪录)

### 游戏公告
Expand Down
12 changes: 4 additions & 8 deletions docs/shopping.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,19 +461,15 @@ For instance, in <https://www.leboncoin.fr/recherche/?**category=10&locations=Pa

<Route author="DIYgod" example="/mi/crowdfunding" path="/mi/crowdfunding"/>

## 小米有品

### 小米有品众筹

<Route author="DIYgod" example="/mi/youpin/crowdfunding" path="/mi/youpin/crowdfunding"/>
<Route author="bigfei" example="/xiaomiyoupin/crowdfunding" path="/xiaomiyoupin/crowdfunding"/>

### 小米有品每日上新

<Route author="xyqfer DIYgod" example="/mi/youpin/new" path="/mi/youpin/new/:sort?" :paramsDesc="['排序,见下表']">

| 个性化排序 | 按销量从高到低 | 按好评从高到低 | 按上新时间从近到远 |
| ----- | ------- | ------- | --------- |
| 0 | 1 | 2 | 3 |

</Route>
<Route author="xyqfer DIYgod bigfei" example="/xiaomiyoupin/latest" path="/xiaomiyoupin/latest" />

## 宜家 IKEA

Expand Down
39 changes: 0 additions & 39 deletions lib/routes/mi/youpin/crowdfunding.js

This file was deleted.

26 changes: 0 additions & 26 deletions lib/routes/mi/youpin/new.js

This file was deleted.

62 changes: 62 additions & 0 deletions lib/v2/famitsu/category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');

const baseUrl = 'https://www.famitsu.com';

module.exports = async (ctx) => {
const { category = 'new-article' } = ctx.params;
const url = `${baseUrl}/search/?category=${category}`;
const { data } = await got(url);
const $ = cheerio.load(data);

const list = $('.col-12 .card__body')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('.card__title').text(),
link: new URL(item.find('.card__title a').attr('href'), baseUrl).href,
pubDate: timezone(parseDate(item.find('time').attr('datetime'), 'YYYY.MM.DDTHH:mm'), +9),
};
})
.filter((item) => item.link.startsWith('https://www.famitsu.com/news/'));

const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = cheerio.load(data);

// remove ads
$('.article-body__contents-pr-primary').remove();

// fix header image
$('.article-body div.media-image').each((_, e) => {
e.tagName = 'img';
e.attribs.src = e.attribs.style.match(/url\((.+?)\);/)[1];
delete e.attribs['data-src'];
delete e.attribs.style;
});

// remove white space
$('.article-body__contents-img-block, .article-body__contents-img-common-col').each((_, e) => {
delete e.attribs.style;
});

item.description = $('.article-body').html();
return item;
})
)
);

ctx.state.data = {
title: $('head title').text(),
description: $('head meta[name="description"]').attr('content'),
image: 'https://www.famitsu.com/img/1812/favicons/apple-touch-icon.png',
link: url,
item: items,
language: 'ja',
};
};
3 changes: 3 additions & 0 deletions lib/v2/famitsu/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/category/:category?': ['TonyRL'],
};
13 changes: 13 additions & 0 deletions lib/v2/famitsu/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'famitsu.com': {
_name: 'ファミ通',
'.': [
{
title: '分类',
docs: 'https://docs.rsshub.app/game.html#ファミ-tong',
source: ['/search'],
target: (_, url) => `/famitsu/category/${new URL(url).searchParams.get('category')}`,
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/famitsu/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/category/:category?', require('./category'));
};
15 changes: 15 additions & 0 deletions lib/v2/xiaomiyoupin/crowdfunding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { parseModule, parseFloorItem } = require('./utils');
const got = require('@/utils/got');

module.exports = async (ctx) => {
const response = await got('https://m.xiaomiyoupin.com/homepage/main/v1005');
const floors = parseModule(response.data.data.homepage.floors, 'crowd_funding');
const items = parseFloorItem(floors);

ctx.state.data = {
title: '小米有品众筹',
link: floors.jump_url,
description: '小米有品众筹',
item: items,
};
};
15 changes: 15 additions & 0 deletions lib/v2/xiaomiyoupin/latest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const got = require('@/utils/got');
const { parseModule, parseFloorItem } = require('./utils');

module.exports = async (ctx) => {
const response = await got('https://m.xiaomiyoupin.com/homepage/main/v1005');
const floors = parseModule(response.data.data.homepage.floors, 'product_hot');
const items = parseFloorItem(floors);

ctx.state.data = {
title: '小米有品每日上新',
link: 'https://m.xiaomiyoupin.com/w/newproduct?pageid=1605',
description: '小米有品每日上新',
item: items,
};
};
4 changes: 4 additions & 0 deletions lib/v2/xiaomiyoupin/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'/crowdfunding': ['bigfei'],
'/latest': ['xyqfer', 'DIYgod', 'bigfei'],
};
19 changes: 19 additions & 0 deletions lib/v2/xiaomiyoupin/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
'xiaomiyoupin.com': {
_name: '小米有品',
'.': [
{
title: '小米有品众筹',
docs: 'https://docs.rsshub.app/shopping.html#xiao-mi-you-pin-xiao-mi-you-pin-zhong-chou',
source: ['/'],
target: '/xiaomiyoupin/crowdfunding',
},
{
title: '小米有品每日上新',
docs: 'https://docs.rsshub.app/shopping.html#xiao-mi-you-pin-xiao-mi-you-pin-mei-ri-shang-xin',
source: ['/'],
target: '/xiaomiyoupin/latest',
},
],
},
};
4 changes: 4 additions & 0 deletions lib/v2/xiaomiyoupin/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = function (router) {
router.get('/crowdfunding', require('./crowdfunding'));
router.get('/latest', require('./latest'));
};
27 changes: 27 additions & 0 deletions lib/v2/xiaomiyoupin/templates/goods.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<figure>
<img src="{{ pic_url || imgs.img800 }}" alt="{{ alt }}" loading="lazy" style="display:block; margin-left:auto; margin-right:auto;" width:100%;>
{{if videos_url }}
<video controls
playsinline="true"
webkit-playsinline="true"
x5-playsinline="true"
x5-video-player-type="h5"
x5-video-orientation="landscape|portrait"
x5-video-player-fullscreen="true"
x-webkit-airplay="allow"
preload="metadata"
poster="{{ pic_url || imgs.img800 }}">
<source src="{{ videos_url[0] }}" type="video/mp4"/>
</video>
{{/if}}

{{if name }}
<figcaption>
<div class="caption">{{@ name }}</div>
<div class="credit">{{@ summary }}</div>
<div class="price">原始价格:{{@ market_price / 100 }}元</div>
<div class="price">实际价格:{{@ (price_min || flash_price) / 100 }}元</div>
</figcaption>
{{/if}}

</figure>
21 changes: 21 additions & 0 deletions lib/v2/xiaomiyoupin/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { art } = require('@/utils/render');
const path = require('path');

const parseModule = (floors, module_key) => floors.filter((floor) => floor.module_key === module_key)[0];

const parseFloorItem = (floor) =>
floor.data.items.map((item) => {
const i = item.item;
return {
title: i.name,
link: i.jump_url,
guid: `xiaomiyoupin:${i.gid}`,
description: art(path.join(__dirname, 'templates/goods.art'), i),
pubDate: (i.start || i.start_time) * 1000,
};
});

module.exports = {
parseModule,
parseFloorItem,
};

1 comment on commit ee813ff

@vercel
Copy link

@vercel vercel bot commented on ee813ff Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.