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 #750 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
16 changed files
with
214 additions
and
73 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,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', | ||
}; | ||
}; |
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,3 @@ | ||
module.exports = { | ||
'/category/:category?': ['TonyRL'], | ||
}; |
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,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')}`, | ||
}, | ||
], | ||
}, | ||
}; |
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,3 @@ | ||
module.exports = (router) => { | ||
router.get('/category/:category?', require('./category')); | ||
}; |
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,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, | ||
}; | ||
}; |
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,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, | ||
}; | ||
}; |
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,4 @@ | ||
module.exports = { | ||
'/crowdfunding': ['bigfei'], | ||
'/latest': ['xyqfer', 'DIYgod', 'bigfei'], | ||
}; |
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,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', | ||
}, | ||
], | ||
}, | ||
}; |
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,4 @@ | ||
module.exports = function (router) { | ||
router.get('/crowdfunding', require('./crowdfunding')); | ||
router.get('/latest', require('./latest')); | ||
}; |
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,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> |
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,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, | ||
}; |
ee813ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rsshub-master – ./
rsshub-master-git-master-auto-bot-ty.vercel.app
rsshub-master-auto-bot-ty.vercel.app
rsshub-master.vercel.app