Skip to content

Commit

Permalink
Merge pull request #1317 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 5, 2024
2 parents 557ec44 + 16d4e59 commit 83ca8df
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const calculateValue = () => {
// Route-specific Configurations
bilibili: {
cookies: bilibili_cookies,
dmImgList: envs.BILIBILI_DM_IMG_LIST,
},
bitbucket: {
username: envs.BITBUCKET_USERNAME,
Expand Down
11 changes: 8 additions & 3 deletions lib/v2/bilibili/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const config = require('@/config').value;
const md5 = require('@/utils/md5');
const CryptoJS = require('crypto-js');

Expand Down Expand Up @@ -86,14 +87,18 @@ function generateGaussianInteger(mean, std) {
}

function getDmImgList() {
const x = Math.max(generateGaussianInteger(720, 20), 0);
const y = Math.max(generateGaussianInteger(480, 20), 0);
if (typeof config.bilibili.dmImgList !== 'undefined') {
const dmImgList = JSON.parse(config.bilibili.dmImgList);
return JSON.stringify([dmImgList[Math.floor(Math.random() * dmImgList.length)]]);
}
const x = Math.max(generateGaussianInteger(650, 5), 0);
const y = Math.max(generateGaussianInteger(400, 5), 0);
const path = [
{
x: 3 * x + 2 * y,
y: 4 * x - 5 * y,
z: 0,
timestamp: Math.max(generateGaussianInteger(40, 5), 0),
timestamp: Math.max(generateGaussianInteger(30, 5), 0),
type: 0,
},
];
Expand Down
10 changes: 6 additions & 4 deletions lib/v2/domp4/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getDomList($, detailUrl) {
return list;
}

function getItemList($, detailUrl) {
function getItemList($, detailUrl, second) {
const encoded = $('.article script[type]')
.text()
.match(/return p}\('(.*)',(\d+),(\d+),'(.*)'.split\(/);
Expand All @@ -39,7 +39,9 @@ function getItemList($, detailUrl) {
.replace(/\\\\"/g, '"')
.replace(/\\\\\\/g, '')
);
const { downurls } = data.Data[0];
// support secondary download address
const { downurls } = second && data.Data.length > 1 ? data.Data[1] : data.Data[0];

return downurls.map((item) => {
const [title, downurl] = item.split('$');
const urlType = getUrlType(downurl);
Expand Down Expand Up @@ -69,7 +71,7 @@ function getMetaInfo($) {

module.exports = async (ctx) => {
const { id } = ctx.params;
const { domain } = ctx.query;
const { domain, second } = ctx.query;
let pureId = id;
let detailType = 'html';
// compatible for .html suffix in radar
Expand All @@ -84,7 +86,7 @@ module.exports = async (ctx) => {

const res = await got(detailUrl);
const $ = cheerio.load(res.data);
const list = getItemList($, detailUrl);
const list = getItemList($, detailUrl, second);
const meta = getMetaInfo($);

ctx.state.data = {
Expand Down
2 changes: 1 addition & 1 deletion lib/v2/domp4/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const config = require('@/config').value;

const defaultDomain = 'mp4us.com';

const allowedDomains = ['domp4.cc', 'mp4kan.com', 'mp4us.com', 'wemp4.com', 'dbmp4.com'];
const allowedDomains = ['domp4.cc', 'mp4us.com', 'wemp4.com', 'dbmp4.com'];

/**
* trackers from https://www.domp4.cc/Style/2020/js/base.js?v=2
Expand Down
41 changes: 41 additions & 0 deletions lib/v2/liveuamap/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { isValidHost } = require('@/utils/valid-host');

module.exports = async (ctx) => {
let region = ctx.params.region ?? 'ukraine';
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 50;
if (!isValidHost(region)) {
throw Error('Invalid region');
}

let url = `https://${region}.liveuamap.com/`;
if (region === undefined) {
region = 'Default';
url = 'https://liveuamap.com/';
}

const response = await got({
method: 'get',
url,
});
const $ = cheerio.load(response.data);

const items = $('div#feedler > div')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('div.title').text(),
description: item.find('div.title').text(),
link: item.attr('data-link'),
};
});

ctx.state.data = {
title: `Liveuamap - ${region}`,
link: url,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/liveuamap/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:region?': ['CoderSherlock'],
};
13 changes: 13 additions & 0 deletions lib/v2/liveuamap/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'liveuamap.com': {
_name: 'Live Universal Awareness Map',
'.': [
{
title: 'Region',
docs: 'https://docs.rsshub.app/routes/new-media#live-universal-awareness-map',
source: ['/:region*'],
target: '/liveuamap/:region',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/liveuamap/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:region?', require('./'));
};
5 changes: 5 additions & 0 deletions website/docs/install/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ See docs of the specified route and `lib/config.js` for detailed information.
2. 打开控制台,切换到 Network 面板,刷新
3. 点击 dynamic_new 请求,找到 Cookie
4. 视频和专栏,UP 主粉丝及关注只要求 `SESSDATA` 字段,动态需复制整段 Cookie
- `BILIBILI_DM_IMG_LIST`: 用于获取UP主投稿系列的路由,获取方式:
1. 打开 [任意UP主个人空间页](https://space.bilibili.com/1)
2. 打开控制台,切换到 Network 面板,关闭缓存,刷新,鼠标在窗口内不断移动
3. 使用过滤器找到符合 `https://api.bilibili.com/x/space/wbi/arc/search` 的请求
4. 复制请求参数中 `dm_img_list` 字段的内容,如 `[{"x":2721,"y":615,"z":0,"timestamp":29,"type":0}]`

### Bitbucket

Expand Down
2 changes: 2 additions & 0 deletions website/docs/routes/multimedia.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ Full transcript support for better user experience.

:::tip
由于大部分详情页是 `/html/xxx.html`,还有部分是 `/detail/123.html`,所以此处做了兼容,id 取 `xxx` 或者 `123` 都可以。

新增 `second` 参数,用于选择下载地址二(地址二不可用或者不填都默认地址一),用法: `/domp4/detail/LBTANI22222I?second=1`
:::

## E-Hentai {#e-hentai}
Expand Down
6 changes: 6 additions & 0 deletions website/docs/routes/new-media.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,12 @@

<Route author="TonyRL" example="/line/today/th/publisher/101048" path="/line/today/:edition/publisher/:id" paramsDesc={['Edition, see table above', 'Channel ID, can be found in URL']} radar="1" />

## Live Universal Awareness Map {#live-universal-awareness-map}

### 实时消息 {#live-universal-awareness-map-shi-shi-xiao-xi}

<Route author="CoderSherlock" example="/liveuamap" path="/liveuamap/:region?" paramsDesc={['region 热点地区,默认为`ukraine`,其他选项见liveuamap.com的三级域名']} anticrawler="1" />

## LVV2 {#lvv2}

### 频道 {#lvv2-pin-dao}
Expand Down

0 comments on commit 83ca8df

Please sign in to comment.