Skip to content

Commit d943879

Browse files
author
Taois
committed
feat: 改了一些源,升级版本
1 parent 4dc8189 commit d943879

File tree

16 files changed

+749
-24
lines changed

16 files changed

+749
-24
lines changed

.env.development

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ MAX_TASK = 8
2626
dingding_webhook=
2727
wechat_webhook=
2828
tx_news_guonei_api_key=
29+
cookie_52pojie=
2930

3031
# QQ邮箱配置
3132
QQ_EMAIL =
3233
QQ_SMTP_AUTH_CODE =
34+
35+
# 调试猫源
3336
CAT_DEBUG=0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# drpyS(drpy-node)
22

33
nodejs作为服务端的drpy实现。全面升级异步写法
4-
~~积极开发中,每日一更~~,当前进度 `72%`
4+
~~积极开发中,每日一更~~,当前进度 `73%`
55
~~找工作中,随缘更新~~
66
上班当牛马,下班要带娃,阶段性佛系趁娃睡觉熬夜更新
77

controllers/api.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ export default (fastify, options, done) => {
4545
// console.log('moduleExt:', typeof moduleExt, moduleExt);
4646
const protocol = request.headers['x-forwarded-proto'] || (request.socket.encrypted ? 'https' : 'http');
4747
const hostname = request.hostname;
48-
// const proxyUrl = `${protocol}://${hostname}${request.url}`.split('?')[0].replace('/api/', '/proxy/') + '/?do=js';
49-
// const proxyUrl = `${protocol}://${hostname}/proxy/${moduleName}/?do=js`;
50-
// console.log('proxyUrl:', proxyUrl);
5148
const publicUrl = `${protocol}://${hostname}/public/`;
5249
const jsonUrl = `${protocol}://${hostname}/json/`;
5350
const httpUrl = `${protocol}://${hostname}/http`;
@@ -334,8 +331,7 @@ export default (fastify, options, done) => {
334331
const fServer = fastify.server;
335332

336333
function getEnv(moduleName) {
337-
// const proxyUrl = `${protocol}://${hostname}/proxy/${moduleName}/?do=js`;
338-
const proxyUrl = `${protocol}://${hostname}${request.url}`.split('?')[0].replace('/parse/', '/proxy/') + '/?do=js';
334+
const proxyUrl = `${protocol}://${hostname}${request.url}`.split('?')[0].replace('/parse/', '/proxy/') + `/?do=${query.do||"ds"}`;
339335
const getProxyUrl = function () {
340336
return proxyUrl
341337
};

docs/apiList.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
- 立即执行全部任务 [/execute-now/:taskName](/execute-now/)
55
- 立即执行钉钉消息任务 [/execute-now/dingtalk_test](/execute-now/dingtalk_test)
66
- 立即执行企业微信消息任务 [/execute-now/wechat_test](/execute-now/wechat_test)
7+
- 立即执行吾爱论坛签到任务 [/execute-now/52pojie_sign](/execute-now/52pojie_sign) | [说明](./cron/52pojie_sign.md)
78
- 获取指定任务信息 [/tasks/:taskName](/tasks/)

docs/cron/52pojie_sign.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### 获取52pojie cookie
2+
3+
1. 手动登录52pojie网站
4+
2. 按下F12或右键检查打开开发者工具,点击网络(network)选项卡
5+
3. 刷新网页,拉动开发者工具界面滑动条到顶部,找到52pojie.cn并点击
6+
4. 开发者工具右侧点击标头(headers),下拉滑动条,找到请求标头(request headers),复制cookie中的 ####
7+
htVC_2132_saltkey=xxxxx;htVC_2132_auth=xxxxxx'两项
8+
5. 复制下拉填到环境变量.env文件里 `cookie_52pojie=` 分号;隔开
9+
10+
## 特殊
11+
12+
论坛网页可能存在爬虫特征校验导致js脚本运行失败,需要验证浏览器环境。
13+
后期考虑使用 golang的 `req/v3` 库来过验证。

docs/updateRecord.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
1. 定时任务 增加 `QQ邮箱` 的消息推送方式
88
2. `cat源` 增加调试模式,但是不支持 `getProxyUrl` 等方法,需要在环境变量.env文件里启用 `CAT_DEBUG=1`
99
详情参考 [猫源调试教程](/docs/catDebug.md)
10+
3. `getProxyUrl` 换成 `getProxy`,兼容T3猫源使用壳子的本地代理,修复 `央视大全` 错误的本地代理获取
11+
4. 修复`番茄小说` 的正文阅读和搜索。分类接口坏的没能力修。央视最新视频高清下载方案目前只有通过 [`CCTV-GO`](https://wwvy.lanzouo.com/ieEq533kiofe) 包含的 `cbox.exe` 本地解密,无法适配本项目。
1012

1113
### 20250813
1214

libs/catvod.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const _config_path = path.join(__dirname, '../config');
1414
const _lib_path = path.join(__dirname, '../spider/catvod');
1515
const enable_cat_debug = Number(process.env.CAT_DEBUG) || 0;
1616

17+
console.log('enable_cat_debug:', enable_cat_debug);
1718

1819
const json2Object = function (json) {
1920
if (!json) {
@@ -34,7 +35,17 @@ const loadEsmWithEnv = async function (filePath, env) {
3435
let injectedCode = rawCode;
3536
const esm_flag1 = 'export function __jsEvalReturn';
3637
const esm_flag2 = 'export default';
37-
const polyfill_code = 'var ENV={};\nvar getProxyUrl=null;\nexport const initEnv = (env)=>{ENV = env;if(env.getProxyUrl){getProxyUrl=env.getProxyUrl}};\n';
38+
const polyfill_code = `
39+
var _ENV={};
40+
var getProxyUrl=null;
41+
var getProxy=null;
42+
export const initEnv = (env)=>{
43+
_ENV = env;
44+
if(env.getProxyUrl){
45+
getProxyUrl=env.getProxyUrl;
46+
getProxy=env.getProxyUrl
47+
}
48+
};`.trim() + '\n';
3849
if (rawCode.includes(esm_flag1)) {
3950
injectedCode = rawCode.replace(esm_flag1, `${polyfill_code}${esm_flag1}`)
4051
} else if (rawCode.includes('export default')) {

scripts/cron/52pojie_sign.mjs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// scripts/52pojie_sign.mjs
2+
import MessageSender from '../../utils/message_sender.js';
3+
import axios from 'axios';
4+
import * as cheerio from 'cheerio';
5+
6+
const cookie = process.env.cookie_52pojie || "";
7+
const headers = {
8+
'Cookie': cookie,
9+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4265.0 Safari/537.36 Edg/87.0.644.4'
10+
};
11+
const url_draw = 'https://www.52pojie.cn/home.php?mod=task&do=draw&id=2';
12+
const url_apply = 'https://www.52pojie.cn/home.php?mod=task&do=apply&id=2';
13+
14+
export default {
15+
schedule: {
16+
// cron: '0 0 7 * * *', // 每天 7:00
17+
timezone: 'Asia/Shanghai', // 直接用北京时间时区
18+
runOnInit: false // 启动时立即执行一次
19+
},
20+
21+
run: async (fastify) => {
22+
if (!cookie) {
23+
return
24+
}
25+
fastify.log.info('📊 开始论坛签到...');
26+
fastify.log.info(`headers: ${JSON.stringify(headers)}`);
27+
try {
28+
// 申请任务
29+
await axios.get(url_apply, {headers});
30+
// 领取任务
31+
const response = await axios.get(url_draw, {headers});
32+
const $ = cheerio.load(response.data);
33+
const username = $('.vwmy a').text();
34+
const message = $('#messagetext p').text();
35+
if (username) {
36+
const msg = `52破解签到信息\n${username}\t${message}`;
37+
fastify.log.info(msg);
38+
await MessageSender.send(msg);
39+
} else {
40+
fastify.log.info(`签到失败,网页内容为:${response.data.slice(0, 300)}`);
41+
}
42+
43+
} catch (error) {
44+
fastify.log.info(`请求出错:${error.message}`);
45+
}
46+
fastify.log.info('📤 论坛签到完成');
47+
}
48+
};

spider/catvod/猫测试.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ function init(ext) {
1313
}
1414

1515
function qjs_test() {
16-
console.log('typeof getProxyUrl:', typeof getProxyUrl);
17-
if (typeof getProxyUrl === 'function') {
18-
console.log('getProxyUrl():', getProxyUrl());
16+
console.log('typeof getProxy:', typeof getProxy);
17+
if (typeof getProxy === 'function') {
18+
console.log('getProxy(true):', getProxy(true));
1919
}
2020
const t1 = Date.now()
2121
let str = '';
@@ -110,7 +110,7 @@ function search(wd, quick) {
110110

111111
function proxy(params) {
112112
console.log("proxy:", params);
113-
console.log('getProxyUrl():', getProxyUrl());
113+
console.log('getProxy():', getProxy());
114114
return [200, 'text/plain;charset=utf-8', 'hello drpyS, 我是猫测试的本地代理', null];
115115
}
116116

spider/catvod/荐片.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ let imghost = `https://${JSON.parse((await req(`${host}/api/appAuthConfig`)).con
1919

2020
//分类数据
2121
async function home(filter) {
22-
// console.log('typeof getProxyUrl:', typeof getProxyUrl);
23-
// if (typeof getProxyUrl === 'function') {
24-
// console.log('getProxyUrl():', getProxyUrl());
22+
// console.log('typeof getProxy:', typeof getProxy);
23+
// if (typeof getProxy === 'function') {
24+
// console.log('getProxy(true):', getProxy(true));
2525
// }
2626
let classes = [{type_id: '1', type_name: '电影',}, {type_id: '2', type_name: '电视剧',}, {
2727
type_id: '3',

0 commit comments

Comments
 (0)