Skip to content

Commit 3db670d

Browse files
authored
Merge pull request #246 from hjdhnx/main
drpy接口增加默认属性【类型】。修复drpy相关ts文件爆红问题
2 parents e184c94 + ece3263 commit 3db670d

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

src/renderer/src/utils/drpy/drpy3.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,20 @@ lsQ9xY0xYPpRZUZKMEeR7e9gmRNLAgMBAAE=
9191
-----END RSA PUBLIC KEY-----
9292
`.trim();
9393

94+
// @ts-ignore
9495
let pkcs1_public_pem = `
9596
MEgCQQCrI0pQ/ERRpJ3Ou190XJedFq846nDYP52rOtXyDxlFK5D3p6JJu2RwsKwy
9697
lsQ9xY0xYPpRZUZKMEeR7e9gmRNLAgMBAAE=
9798
`.trim();
9899

100+
// @ts-ignore
99101
let pkcs8_public = `
100102
-----BEGIN PUBLIC KEY-----
101103
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKsjSlD8RFGknc67X3Rcl50WrzjqcNg/
102104
nas61fIPGUUrkPenokm7ZHCwrDKWxD3FjTFg+lFlRkowR5Ht72CZE0sCAwEAAQ==
103105
-----END PUBLIC KEY-----`.trim();
104106

107+
// @ts-ignore
105108
let pkcs8_public_pem = `
106109
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKsjSlD8RFGknc67X3Rcl50WrzjqcNg/
107110
nas61fIPGUUrkPenokm7ZHCwrDKWxD3FjTFg+lFlRkowR5Ht72CZE0sCAwEAAQ==
@@ -119,6 +122,7 @@ EJNBXVRTK42SNsZ2hJ/9xLwOwnH2epT8Q43s3Q==
119122
-----END RSA PRIVATE KEY-----
120123
`.trim()
121124

125+
// @ts-ignore
122126
let pkcs8_private = `
123127
-----BEGIN PRIVATE KEY-----
124128
MIIBUgIBADANBgkqhkiG9w0BAQEFAASCATwwggE4AgEAAkEAqyNKUPxEUaSdzrtf
@@ -263,7 +267,7 @@ const pre = () => {
263267
let rule = {};
264268
// @ts-ignore
265269
let vercode = typeof pdfl === 'function' ? 'drpy3.1' : 'drpy3';
266-
const VERSION = `${vercode} 3.9.50beta24 20240601`;
270+
const VERSION = `${vercode} 3.9.50beta25 20240604`;
267271
/** 已知问题记录
268272
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
269273
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
@@ -291,7 +295,7 @@ const IOS_UA =
291295
const RULE_CK = 'cookie'; // 源cookie的key值
292296
// const KEY = typeof(key)!=='undefined'&&key?key:'drpy_' + (rule.title || rule.host); // 源的唯一标识
293297
const CATE_EXCLUDE = '首页|留言|APP|下载|资讯|新闻|动态';
294-
const TAB_EXCLUDE = '猜你|喜欢|下载|剧情|热播';
298+
const TAB_EXCLUDE = '猜你|喜欢|下载|剧情|榜|评论';
295299
const OCR_RETRY = 3; // ocr验证重试次数
296300
// const OCR_API = 'http://drpy.nokia.press:8028/ocr/drpy/text';//ocr在线识别接口
297301
const OCR_API = 'https://api.nn.ci/ocr/b64/text';//ocr在线识别接口
@@ -614,6 +618,7 @@ Object.defineProperty(Object.prototype, 'myValues', {
614618
var res=[]
615619
for(var k in obj){
616620
if(obj.hasOwnProperty(k)){//需判断是否是本身的属性
621+
// @ts-ignore
617622
res.push(obj[k]);
618623
}
619624
}
@@ -631,6 +636,7 @@ if (typeof Object.prototype.values != 'function') {
631636
var res=[]
632637
for(var k in obj){
633638
if(obj.hasOwnProperty(k)){//需判断是否是本身的属性
639+
// @ts-ignore
634640
res.push(obj[k]);
635641
}
636642
}
@@ -984,6 +990,7 @@ const RSA = {
984990
decode(data, key, option) {
985991
option = option || {};
986992
if (typeof JSEncrypt === 'function') {
993+
// @ts-ignore
987994
const chunkSize = option.chunkSize ?? 117; // 默认分段长度为117
988995
const privateKey = this.getPrivateKey(key);
989996
const decryptor = new JSEncrypt();
@@ -995,6 +1002,7 @@ const RSA = {
9951002
encode(data, key, option ) {
9961003
option = option || {};
9971004
if (typeof JSEncrypt === 'function') {
1005+
// @ts-ignore
9981006
const chunkSize = option.chunkSize ?? 117; // 默认分段长度为117
9991007
const publicKey = this.getPublicKey(key);
10001008
const encryptor = new JSEncrypt();
@@ -1113,13 +1121,14 @@ const fixAdM3u8 = (m3u8_text: string, m3u8_url: string, ad_remove: string) => {
11131121
return m3u8_text;
11141122
};
11151123

1124+
11161125
/**
11171126
* 智能对比去除广告。支持嵌套m3u8。只需要传入播放地址
11181127
* @param m3u8_url m3u8播放地址
11191128
* @param headers 自定义访问m3u8的请求头,可以不传
11201129
* @returns {string}
11211130
*/
1122-
const fixAdM3u8Ai = (m3u8_url: string, headers:object=null) => {
1131+
const fixAdM3u8Ai = (m3u8_url: string, headers:object|null=null) => {
11231132
let ts = new Date().getTime();
11241133
let option = headers ? {headers:headers}:{};
11251134

@@ -1494,7 +1503,7 @@ const jq = parseTags.jq;
14941503
* @returns {string}
14951504
*/
14961505
const readFile = (filePath) => {
1497-
// filePath = filePath || './uri.min.js';
1506+
filePath = filePath || './uri.min.js';
14981507
// var fd = os.open(filePath);
14991508
// var buffer = new ArrayBuffer(1024);
15001509
// var len = os.read(fd, buffer, 0, 1024);
@@ -1548,6 +1557,7 @@ var OcrApi = {
15481557
}
15491558
code = html || '';
15501559
} catch (e) {
1560+
// @ts-ignore
15511561
log(`OCR识别验证码发生错误:${e.message}`)
15521562
}
15531563
return code
@@ -1799,6 +1809,7 @@ const request = (url: string, obj: any = undefined, ocr_flag: boolean = false) =
17991809
* @returns {string|DocumentFragment|*}
18001810
*/
18011811
const post = (url: string, obj:object={}) => {
1812+
// @ts-ignore
18021813
obj.method = 'POST';
18031814
return request(url, obj);
18041815
};
@@ -1812,6 +1823,7 @@ const post = (url: string, obj:object={}) => {
18121823
* @returns {{cookie: string, html: (*|string|DocumentFragment)}}
18131824
*/
18141825
const reqCookie = (url:string, obj:object={}, all_cookie:boolean=false) => {
1826+
// @ts-ignore
18151827
obj.withHeaders = true;
18161828
let html = request(url, obj);
18171829
let json = JSON.parse(html);
@@ -3027,21 +3039,24 @@ function getOriginalJs(js_code){
30273039
* @param arg
30283040
*/
30293041
function runMain(main_func_code, arg){
3042+
// @ts-ignore
30303043
let mainFunc = function(arg){return ''};
30313044
try {
30323045
eval(main_func_code+'\nmainFunc=main;');
30333046
return mainFunc(arg);
30343047
}catch (e) {
3048+
// @ts-ignore
30353049
log(`执行main_funct发生了错误:${e.message}`);
30363050
return ''
30373051
}
30383052
}
30393053

3054+
// @ts-ignore
30403055
/**
30413056
* js源预处理特定返回对象中的函数
30423057
* @param ext
30433058
*/
3044-
const init = (ext) => {
3059+
const init = (ext:string|object) => {
30453060
console.log('[t3]init');
30463061
// init前重置rule和fetch_params
30473062
rule = {};
@@ -3071,6 +3086,7 @@ const init = (ext) => {
30713086
ext = getOriginalJs(ext);
30723087
// eval(ext.replace('var rule', 'rule'));
30733088
// eval("(function(){'use strict';"+ext.replace('var rule', 'rule')+"})()");
3089+
// @ts-ignore
30743090
eval("(function(){"+ext.replace('var rule', 'rule')+"})()");
30753091
}
30763092
}
@@ -3098,6 +3114,7 @@ const init = (ext) => {
30983114
console.log(`[t3][publish]执行${rule['hostJs']}获取host发生错误:${e}`);
30993115
}
31003116
}
3117+
rule['类型'] = rule['类型'] || '影视'; // 影视|听书|漫画|小说
31013118
rule['url'] = rule['url'] || '';
31023119
rule['double'] = rule['double'] || false;
31033120
rule['homeUrl'] = rule['homeUrl'] || '';
@@ -3186,6 +3203,11 @@ const init = (ext) => {
31863203
return init_test();
31873204
} catch (e) {
31883205
console.info('[t3][init]init_test发生错误:', e);
3206+
return {
3207+
version: VERSION,
3208+
rkey: RKEY,
3209+
rule: {},
3210+
}
31893211
}
31903212
};
31913213

src/renderer/src/utils/drpy/drpyInject.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const baseRequest = (_url: string, _object: RequestOptions, _js_type: number = 0
101101
headers = keysToLowerCase(headers);
102102
// 从content-type拿到正确的网页编码
103103
if(headers['content-type'] && /charset=(.*)/i.test(headers['content-type'])){
104+
// @ts-ignore
104105
encoding = headers['content-type'].match(/charset=(.*)/i)[1].split(';')[0].trim();
105106
}
106107

src/renderer/src/utils/drpy/drpy_suggestions/drpy_suggestions.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const Snippet = [
6565
label: '$rule',
6666
insertText: `
6767
var rule = {
68+
类型:'影视',//影视|听书|漫画|小说
6869
title:'',
6970
host:'',
7071
url:'',
@@ -110,6 +111,7 @@ var rule = {
110111
label: '$ruleJs',
111112
insertText: `
112113
var rule = {
114+
类型:'影视',//影视|听书|漫画|小说
113115
title:'',
114116
host:'',
115117
url:'',
@@ -181,10 +183,20 @@ Object.assign(muban.mxone5.二级,{
181183
detail: '继承模板前修改模板的二级属性',
182184
documentation: `Object.assign(muban.xx模板.xx属性,{})`,
183185
},
186+
{
187+
label: '$getOriginalJs',
188+
insertText: `
189+
let a = \`\`.trim();
190+
console.log(getOriginalJs(a));
191+
`.trim(),
192+
detail: '获取加密前的js源代码',
193+
documentation: `getOriginalJs(js_code)`,
194+
},
184195
{
185196
label: '$ruleTemplate',
186197
insertText: `
187198
var rule = {
199+
类型:'影视',//影视|听书|漫画|小说
188200
title:'规则标题',
189201
编码:'utf-8',
190202
搜索编码:'utf-8',
@@ -878,43 +890,51 @@ const Variable = [
878890
const createDependencyProposals = (range: object, monaco: any) => {
879891
let suggestions = [];
880892
// 代码片段
893+
// @ts-ignore
881894
let suggestions_27 = Snippet.map((it) => {
882895
Object.assign(it, {
883896
kind: monaco.languages.CompletionItemKind.Snippet,
884897
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
885898
range: range,
886899
});
900+
// @ts-ignore
887901
suggestions.push(it);
888902
return it;
889903
});
890904
// 函数
905+
// @ts-ignore
891906
let suggestions_1 = Function.map((it) => {
892907
Object.assign(it, {
893908
kind: monaco.languages.CompletionItemKind.Function,
894909
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
895910
range: range,
896911
});
912+
// @ts-ignore
897913
suggestions.push(it);
898914
return it;
899915
});
900916
// 关键词
917+
// @ts-ignore
901918
let suggestions_17 = Keyword.map((it) => {
902919
Object.assign(it, {
903920
kind: monaco.languages.CompletionItemKind.Keyword,
904921
insertTextRules: monaco.languages.CompletionItemInsertTextRule.None,
905922
range: range,
906923
});
924+
// @ts-ignore
907925
suggestions.push(it);
908926
return it;
909927
});
910928

911929
// 变量
930+
// @ts-ignore
912931
let suggestions_4 = Variable.map((it) => {
913932
Object.assign(it, {
914933
kind: monaco.languages.CompletionItemKind.Variable,
915934
insertTextRules: monaco.languages.CompletionItemInsertTextRule.None,
916935
range: range,
917936
});
937+
// @ts-ignore
918938
suggestions.push(it);
919939
return it;
920940
});

src/renderer/src/utils/drpy/htmlParser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class Jsoup {
173173
return res;
174174
}
175175

176+
// @ts-ignore
176177
pdfl(html: string, parse: string, list_text: string, list_url: string, url_key: string): string[] {
177178
if (!html || !parse) return [];
178179
parse = this.parseHikerToJq(parse, false);
@@ -280,6 +281,7 @@ class Jsoup {
280281
ret = `${ret}`;
281282
}
282283

284+
// @ts-ignore
283285
return ret;
284286
}
285287

src/renderer/src/utils/drpy/template.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ const getMubans = () => {
164164
'ul.stui-vodlist__media&&li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
165165
},
166166
默认: {
167+
类型:'影视',//影视|听书|漫画|小说
167168
title: '',
168169
host: '',
169170
url: '',

0 commit comments

Comments
 (0)