mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add babehub (#7070)
Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
co-authored by
NeverBehave
parent
9b9a9d8c99
commit
bfff2c55d3
@@ -36,6 +36,22 @@ pageClass: routes
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## BabeHub
|
||||
|
||||
### Category
|
||||
|
||||
<RouteEn author="nczitzk" example="/babehub" path="/babehub/:category?" :paramsDesc="['Category, see below, Home by default']">
|
||||
|
||||
| Home | Most Viewed | Picture Archive | Video Archive |
|
||||
| - | - | - | - |
|
||||
| | most-viewed | picture | video |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
### Search
|
||||
|
||||
<RouteEn author="nczitzk" example="/babehub/search/babe" path="/babehub/search/:keyword?" :paramsDesc="['关键字']"/>
|
||||
|
||||
## Bing Wallpaper
|
||||
|
||||
### Daily Wallpaper
|
||||
|
||||
@@ -46,6 +46,22 @@ pageClass: routes
|
||||
|
||||
<Route author="KotoriK" example="/8kcos/cat/8kasianidol" path="/8kcos/cat/:cat*" :paramsDesc="['默认值为8kasianidol,将目录页面url中 /category/ 后面的部分填入。如:https://www.8kcosplay.com/category/8kchineseidol/%e9%a3%8e%e4%b9%8b%e9%a2%86%e5%9f%9f/ 对应的RSS页面为/8kcos/cat/8kchineseidol/%e9%a3%8e%e4%b9%8b%e9%a2%86%e5%9f%9f/。']"/>
|
||||
|
||||
## BabeHub
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/babehub" path="/babehub/:category?" :paramsDesc="['分类,见下表,默认为首页']">
|
||||
|
||||
| Home | Most Viewed | Picture Archive | Video Archive |
|
||||
| ---- | ----------- | --------------- | ------------- |
|
||||
| | most-viewed | picture | video |
|
||||
|
||||
</Route>
|
||||
|
||||
### 搜索关键字
|
||||
|
||||
<Route author="nczitzk" example="/babehub/search/babe" path="/babehub/search/:keyword?" :paramsDesc="['关键字']"/>
|
||||
|
||||
## Bing 壁纸
|
||||
|
||||
### 每日壁纸
|
||||
|
||||
@@ -3936,6 +3936,10 @@ router.get('/tianyancha/hot', require('./routes/tianyancha/hot'));
|
||||
// King Arthur
|
||||
router.get('/kingarthur/:type', require('./routes/kingarthur/index'));
|
||||
|
||||
// BabeHub
|
||||
router.get('/babehub/search/:keyword?', require('./routes/babehub/search'));
|
||||
router.get('/babehub/:category?', require('./routes/babehub/index'));
|
||||
|
||||
// 深圳新闻网
|
||||
router.get('/sznews/ranking', require('./routes/sznews/ranking'));
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
const utils = require('./utils');
|
||||
|
||||
const categories = {
|
||||
'most-viewed': {
|
||||
url: 'most-viewed',
|
||||
title: 'Most Viewed',
|
||||
},
|
||||
picture: {
|
||||
url: 'picture-archive',
|
||||
title: 'Pictures',
|
||||
},
|
||||
video: {
|
||||
url: 'video-archive',
|
||||
title: 'Videos',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category || '';
|
||||
const title = `${category ? `${categories[category].title} - ` : ''}BabeHub`;
|
||||
|
||||
const currentUrl = `${utils.rootUrl}/${category ? categories[category].url : ''}`;
|
||||
|
||||
ctx.state.data = {
|
||||
title,
|
||||
link: currentUrl,
|
||||
itunes_author: title,
|
||||
item: await utils.fetch(ctx.cache, currentUrl),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const keyword = ctx.params.keyword || '';
|
||||
const title = `${keyword ? `Search ${keyword} - ` : ''}BabeHub`;
|
||||
|
||||
const currentUrl = `${utils.rootUrl}/${keyword ? `?s=${keyword}` : ''}`;
|
||||
|
||||
ctx.state.data = {
|
||||
title,
|
||||
link: currentUrl,
|
||||
itunes_author: title,
|
||||
item: await utils.fetch(ctx.cache, currentUrl),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const rootUrl = 'https://www.babehub.com';
|
||||
|
||||
const fetch = async (cache, currentUrl) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.gallery-d li')
|
||||
.slice(0, 50)
|
||||
.map((_, item) => {
|
||||
item = $(item).children('a').eq(0);
|
||||
const image = item.find('img').eq(0);
|
||||
const date = item.find('.date').text();
|
||||
|
||||
return {
|
||||
link: item.attr('href'),
|
||||
title: item.attr('title') || image.attr('alt'),
|
||||
itunes_item_image: image.attr('src'),
|
||||
pubDate: (date ? new Date(date.replace(/st|nd|rd|th/g, '')) : new Date()).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await cache.tryGet(item.link, async () => {
|
||||
try {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
const video = content('video');
|
||||
|
||||
item.description = '';
|
||||
|
||||
if (video.length > 0) {
|
||||
const poster = detailResponse.data.match(/posterImage: "(.*)",/);
|
||||
item.itunes_item_image = (poster ? poster[1] : video.attr('poster')) || item.itunes_item_image;
|
||||
|
||||
item.enclosure_type = 'video/mp4';
|
||||
item.enclosure_url = video.children('source').attr('src');
|
||||
item.description = `<video controls loop preload="auto"><source src=${item.enclosure_url} type="video/mp4"/></video><img src="${item.itunes_item_image}">`;
|
||||
}
|
||||
|
||||
content('.gallery-e li a').each(function () {
|
||||
item.description += `<img src="${content(this).attr('href')}">`;
|
||||
});
|
||||
|
||||
return item;
|
||||
} catch (e) {
|
||||
return Promise.resolve('');
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return items;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
rootUrl,
|
||||
fetch,
|
||||
};
|
||||
Reference in New Issue
Block a user