Add files via upload

This commit is contained in:
n3rddd 2024-04-25 22:33:05 +08:00 committed by GitHub
parent bd13fbff60
commit 8f39b5e39b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 644 additions and 82 deletions

View File

@ -55,7 +55,7 @@ function pre(){
}
let rule = {};
const VERSION = 'drpy1 3.9.49beta2 20231122';
const VERSION = 'drpy1 3.9.49beta36 202400414';
/**
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼最新的文件发现这问题已经解决了]
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
@ -1082,6 +1082,9 @@ function request(url,obj,ocr_flag){
obj.buffer = 2;
delete obj.toBase64
}
if(obj.redirect===false){
obj.redirect = 0;
}
console.log(JSON.stringify(obj.headers));
// console.log('request:'+url+' obj:'+JSON.stringify(obj));
console.log('request:'+url+`|method:${obj.method||'GET'}|body:${obj.body||''}`);
@ -1447,6 +1450,15 @@ function homeVodParse(homeVodObj){
let t2 = (new Date()).getTime();
console.log('加载首页推荐耗时:'+(t2-t1)+'毫秒');
// console.log(JSON.stringify(d));
if(rule.图片替换 && rule.图片替换.includes('=>')){
let replace_from = rule.图片替换.split('=>')[0];
let replace_to = rule.图片替换.split('=>')[1];
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
it.vod_pic = it.vod_pic.replace(replace_from,replace_to);
}
});
}
if(rule.图片来源){
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
@ -1585,6 +1597,15 @@ function categoryParse(cateObj) {
console.log(e.message);
}
}
if(rule.图片替换 && rule.图片替换.includes('=>')){
let replace_from = rule.图片替换.split('=>')[0];
let replace_to = rule.图片替换.split('=>')[1];
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
it.vod_pic = it.vod_pic.replace(replace_from,replace_to);
}
});
}
if(rule.图片来源){
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
@ -1776,6 +1797,15 @@ function searchParse(searchObj) {
return '{}'
}
}
if(rule.图片替换 && rule.图片替换.includes('=>')){
let replace_from = rule.图片替换.split('=>')[0];
let replace_to = rule.图片替换.split('=>')[1];
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
it.vod_pic = it.vod_pic.replace(replace_from,replace_to);
}
});
}
if(rule.图片来源){
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
@ -2070,6 +2100,11 @@ function detailParse(detailObj){
}
vod.vod_play_url = vod_play_url;
}
if(rule.图片替换 && rule.图片替换.includes('=>')){
let replace_from = rule.图片替换.split('=>')[0];
let replace_to = rule.图片替换.split('=>')[1];
vod.vod_pic = vod.vod_pic.replace(replace_from,replace_to);
}
if(rule.图片来源 && vod.vod_pic && vod.vod_pic.startsWith('http')){
vod.vod_pic = vod.vod_pic + rule.图片来源;
}
@ -2169,6 +2204,7 @@ function tellIsJx(url){
function playParse(playObj){
fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
MY_URL = playObj.url;
var MY_FLAG = playObj.flag;
if(!/http/.test(MY_URL)){
try {
MY_URL = base64Decode(MY_URL);
@ -2176,9 +2212,11 @@ function playParse(playObj){
}
MY_URL = decodeURIComponent(MY_URL);
var input = MY_URL;//注入给免嗅js
var flag = MY_FLAG;//注入播放线路名称给免嗅js
let common_play = {
parse:1,
url:input,
flag:flag,
// url:urlencode(input),
jx:tellIsJx(input)
};
@ -2363,6 +2401,7 @@ function isVideoParse(isVideoObj){
rule.encoding = rule.编码||rule.encoding||'utf-8';
rule.search_encoding = rule.搜索编码||rule.search_encoding||'';
rule.图片来源 = rule.图片来源||'';
rule.图片替换 = rule.图片替换||'';
rule.play_json = rule.hasOwnProperty('play_json')?rule.play_json:[];
rule.pagecount = rule.hasOwnProperty('pagecount')?rule.pagecount:{};
rule.proxy_rule = rule.hasOwnProperty('proxy_rule')?rule.proxy_rule:'';

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
import cheerio from 'assets://js/lib/cheerio.min.js';
import 'assets://js/lib/crypto-js.js';
import 模板 from"../js/模板.js"
import './jsencrypt.js';
import 模板 from "../js/模板.js"
import {gbkTool} from './gbk.js'
// import './rsa.js'
// import cheerio from "https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/cheerio.min.js";
// import "https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/crypto-js.js";
@ -19,21 +19,26 @@ function init_test(){
console.log(JSON.stringify(rule));
console.log("init_test_end");
// console.log(typeof (CryptoJS));
// console.log(typeof (JSEncrypt));
// var publicKey = "-----BEGIN PUBLIC KEY-----\n" +
// "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDTTt5d1LYtIxiW9ekKFBVonFOT\n" +
// "XJHv4PY4xCDLPYbHWRKa/mRO7J11OJX+cR7bqzNq6uxH1W339wV\n" +
// "lLP/x3Rl1RBh4prj0eYOEIsDVTvLTJONKazRtQrZ7yzSZ69o/3CQv\n" +
// "ex6kb4js+9zho4U9fwIDAQAB\n" +
// "-----END PUBLIC KEY-----";
// var text = '你好';
// const encryptor = new JSEncrypt();
// console.log(typeof (encryptor.setPublicKey));
// console.log(typeof (encryptor.encrypt));
// encryptor.setPublicKey(publicKey) // 设置公钥
// var str = encryptor.encrypt(text) // 对数据进行加密
// log('typeof (JSEncrypt):'+typeof (JSEncrypt));
// let publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwEc7wBMtYKkxvrQNI3+ITBZwAkPkGvsv4TsAHFskKGZWz9eYl3scivhmlEfWHlEkdyb0m82CmB1qAgef+pD4cZu+Cdmm2e9lnExhLwm8cBgpkAen9QRNdjojZgxM0W+JcReH4W6pw+uFXiLRn4AIQkDftWGNLg6wlNS+39Z/RvP9zyATJLZ9AKDdHp62XMxEK1KZvWBuIg+Oa5UzgA9jy+2XyIqwhBtO8tPbUl21t2pvTzHoLUjSkPNm2LurcUk6+jQ2r6aiS2CN1NXIucPJU6mkuIQ821SjvkYPtIdRMntW4y2u4cyiqVEEQwlzWVMHh+/vfrWAQr9fgjDuYYtvPQIDAQAB';
// let privateKey = 'MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDARzvAEy1gqTG+tA0jf4hMFnACQ+Qa+y/hOwAcWyQoZlbP15iXexyK+GaUR9YeUSR3JvSbzYKYHWoCB5/6kPhxm74J2abZ72WcTGEvCbxwGCmQB6f1BE12OiNmDEzRb4lxF4fhbqnD64VeItGfgAhCQN+1YY0uDrCU1L7f1n9G8/3PIBMktn0AoN0enrZczEQrUpm9YG4iD45rlTOAD2PL7ZfIirCEG07y09tSXbW3am9PMegtSNKQ82bYu6txSTr6NDavpqJLYI3U1ci5w8lTqaS4hDzbVKO+Rg+0h1Eye1bjLa7hzKKpUQRDCXNZUweH7+9+tYBCv1+CMO5hi289AgMBAAECggEBAIRbRJUWXmEwdq64kGbELlV6CIZ2p3mvOSlIjO34Cy7IK7AMz9xOgbpj/XDK9miOIJTouu7ZC7GcZdGZ4BUCYBMMS0fKjGFuurpZlXhkslNTPqEHtCUkXhIpOR7RDrwIlErGEOIsZC4aXQcM3tF1t7mroJLh4OY4dHMu82lv5NM4hhFMNvHzXVvrPXeTzw26gddHVG/ke0WUYOcB5j3cPp8xaVp7JV8bdxtGtkqIfBLY/dIczzJu/3F3cBpU2nNwt8uVUF/w/HKlr7j8FqqFHXWh182beU0n5AIdRyRJBrRUAEhdtsUnvJOVBDqzZa+9DJ5395F7V8KRlQptxETdhCECgYEA4x/2HM9fnVIhG6wTbEt1LhGTKYb/igMAHLqquEMfRsB44tobI8gVNwR3qJQY/nKXxcQemQV29PcdqpENCKyXUXGD8SI1UPg15rHFBI8CIqlCXfzJybdHjmzlhaA9I5lofIVh+5MW7WkvHZoRy7NeDMhHUuaiveuqC4OJ8n+dD2kCgYEA2LkmUVef3WkBBwUBRdkyoog3DMwR+/ubb0ncJVYy3ItYVJltQ4HqmrRiJc8xBAoFnG8rbiqDnmTnDR3WbuxU1G2hml09fqId+rQds2UfESswCXHU43A4f77m1XyA6PprBxpozVIcmK69N4rR9jOXflLWo3O+p2ipUbmNpId7+rUCgYBSpcbBJRT+AmzZzPwkZDD32p1ady114zGfQq3s7z/qVw+mPQezNZPCuXVxerK9pKVl6b/Ynwxyh5nb/3xms6c8k7oXfQM5u5ihof63cfKs+jqUSPCE3pTDVw0OWwjkc2Z6KW9GRHgLXEMw2mevYE3RCPArUpHV2nO+TNddzuIwQQKBgQDOZwdnUNygMfEYjlu3+jOPN8u2FGTMZ8SRKPbRWFb4VH27lKPLN2AIFuOivsEf56uQYRAry7GumMq0Y0ZmPg5Mglz2dvaqNBv5OLFQuW3tHAST+iWWtroYb+fISts7B8QG79AAO8OgZksvKrbslBYj6SEiaomZRsR7YQzVNXOOQQKBgQCovElZ50c8ZJ6m9D9fw3Nes7u9vshpyyac5tt4tZ7yfU4l5pWGrIUqCE703qZp4NAqEvlZUCJbj9kkysaj/2MfFb2b9jSvdNB+V/YW9Cwg+5TziYoOcQzN1z2u4p4goTAv0S+pTNSr3qWaTUI4TXUXQajif45Fexv+MrP5AAXQyw=='
// // let text = '你好';
// let text = '[{"vod_name":"兔小贝原创儿歌","vod_pic":"https://resource-cdn.tuxiaobei.com/video-album/FnQ8ieJHgsbgCKWXNBg4uoOmKgG5.jpg","vod_remarks":"共229首","vod_content":"","vod_id":"/subject/17@@兔小贝原创儿歌@@https://resource-cdn.tuxiaobei.com/video-album/FnQ8ieJHgsbgCKWXNBg4uoOmKgG5.jpg"},{"vod_name":"英文儿歌","vod_pic":"https://resource-cdn.tuxiaobei.com/video-album/Fqjpx2H_-QaYNAYn2MekRuDpeyUv.jpg","vod_remarks":"共10首","vod_content":"","vod_id":"/subject/23@@英文儿歌@@https://resource-cdn.tuxiaobei.com/video-album/Fqjpx2H_-QaYNAYn2MekRuDpeyUv.jpg"}]';
// let str = RSA.encode(text, publicKey);
// console.log("加密数据:" + str);
// let str1 = 'Wa2c/868VOm0PgpGG2s2aMrDbGOlJRdZXlSGswjFgywd3nZNB7ND8kVMdNB/OsNFoQXJXSJMvPaE73BH7rs8fz54JGdYQK+qTgfQRqQZvomCjbzseSR4bm4NOrtIOOslL3WqxlzOuU0M1P1eERmkLEVU2WSyc3RGtJro3b3MOWYCNdKMoZdncfOHJndkl4wm9V3GGc3uH98hs6OxLvBWgXoW9jZQ3n0vR2FtS2KYrPGuSuKGkxlt9Kw5TD6nri142NOimz05WK55Xe04YUQ1VZd51t0wzJGXolWgfzIQaK2zzhk5Zjlm+IQJxXqEWiJ2+O6TJ+lIttvsDSaUflcDXQ==';
// let str2 = 'R86mW9DzBw05pxBSh9ECh1stXxINmnudgZBbzU/cz1EcFgrEgdk0Zk4ruAiJZB2fP5c7d3gMmN8+Dv19IfARWSzw85xCEjUhpdcMJ0jn6ZE5H+muadND9LzjeVisojqwYxot3YVdKof7HMhPFN8QR0jfzqhjmnGFTlY1jMXzJK0MSOLNRLDar480CdKNb/cxALC8+xKIlhM9E4B31t8J4rNMUWSCAr49lbZ3jx3PxieBpTQUdDJz96AttR93Pc+c51wrxh0Ch/Mt4Rs09HGMXwIpNV+CxsGwSGRQUlyJo2k3d0WqsVzpz6S8A4VGEMTRLGI3IjEt+eWt7wM3nAXarg==';
// let str3 = 'D4eOsRqua+jYA5+ZOR9PLI2PExKjKfArQfv9/wGeG50bQSjWypShJPY6RQfO+rghyf0juzHIUSxqH91OxinhCFkONaF2Vod2QVyphyn9eh73dAcEFKIFFKGXoPCjbMWrr3p4d+hgVrHzrFeGqkRq8JFOvG2L5XDxVfWbV8KmUA0DKuz6QwWg7P4kesy+C7BbLALy5W/wfZchD3gnsBvx/pjFoe11VfAify9isLxg9a15jj52xr6lzQ9kge9C2JcV8yq85bFKaUpJWgobzz+BSIv3lVMU6vgcldmOrhkyiETpFGFGGF00DphGCEoK6uAyyNDh7+Jn8P17zf/DW1wV3A==';
// let uncrypted = RSA.decode(str, privateKey);
// log('解密数据:'+uncrypted);
// uncrypted = RSA.decode(str1, privateKey);
// log('解密数据1:'+uncrypted);
// uncrypted = RSA.decode(str2, privateKey);
// log('解密数据2:'+uncrypted);
// uncrypted = RSA.decode(str3, privateKey);
// log('解密数据3:'+uncrypted);
// log('rsax:'+typeof(rsax));
// log('rsaX:'+typeof(rsaX));
// let data = base64Encode('你好');
@ -67,7 +72,7 @@ function pre(){
let rule = {};
let vercode = typeof(pdfl) ==='function'?'drpy2.1':'drpy2';
const VERSION = vercode+' 3.9.49beta2 20231122';
const VERSION = vercode+' 3.9.49beta40 202400425';
/**
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼最新的文件发现这问题已经解决了]
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
@ -136,10 +141,10 @@ const SELECT_REGEX_A = /:eq|:lt|:gt/g;
*/
if (typeof Object.assign != 'function') {
Object.assign = function () {
var target = arguments[0];
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
let target = arguments[0];
for (let i = 1; i < arguments.length; i++) {
let source = arguments[i];
for (let key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
@ -451,29 +456,62 @@ function getCryptoJS(){
// 封装的RSA加解密类
const RSA = {
encode:function (data,key,option){
// log('encode');
if(typeof(rsaEncrypt)==='function'){
if(!option||typeof(option)!=='object'){
return rsaEncrypt(data,key);
}else{
return rsaEncrypt(data,key,option);
}
}else{
decode: function (data, key, option) {
option = option || {};
if (typeof (JSEncrypt) === 'function') {
let chunkSize = option.chunkSize || 117; // 默认分段长度为117
let privateKey = this.getPrivateKey(key); // 获取私钥
const decryptor = new JSEncrypt(); //创建解密对象实例
decryptor.setPrivateKey(privateKey); //设置秘钥
let uncrypted = '';
// uncrypted = decryptor.decrypt(data);
uncrypted = decryptor.decryptUnicodeLong(data);
return uncrypted;
} else {
return false
}
},
decode:function (data,key,option){
// log('decode');
if(typeof(rsaDecrypt)==='function'){
if(!option||typeof(option)!=='object'){
return rsaDecrypt(data,key);
}else{
return rsaDecrypt(data,key,option);
}
}else{
encode: function (data, key, option) {
option = option || {};
if (typeof (JSEncrypt) === 'function') {
let chunkSize = option.chunkSize || 117; // 默认分段长度为117
let publicKey = this.getPublicKey(key); // 获取公钥
const encryptor = new JSEncrypt();
encryptor.setPublicKey(publicKey); // 设置公钥
let encrypted = ''; // 加密结果
// const textLen = data.length; // 待加密文本长度
// let offset = 0; // 分段偏移量
// // 分段加密
// while (offset < textLen) {
// let chunk = data.slice(offset, chunkSize); // 提取分段数据
// let enc = encryptor.encrypt(chunk); // 加密分段数据
// encrypted += enc; // 连接加密结果
// offset += chunkSize; // 更新偏移量
// }
encrypted = encryptor.encryptUnicodeLong(data);
return encrypted
} else {
return false
}
},
fixKey(key, prefix, endfix) {
if (!key.includes(prefix)) {
key = prefix + key;
}
if (!key.includes(endfix)) {
key += endfix
}
return key
},
getPrivateKey(key) {
let prefix = '-----BEGIN RSA PRIVATE KEY-----';
let endfix = '-----END RSA PRIVATE KEY-----';
return this.fixKey(key, prefix, endfix);
},
getPublicKey(key) {
let prefix = '-----BEGIN PUBLIC KEY-----';
let endfix = '-----END PUBLIC KEY-----';
return this.fixKey(key, prefix, endfix);
}
};
@ -489,6 +527,153 @@ function getProxyUrl(){
}
}
/**
* 根据正则处理原始m3u8里的广告ts片段自动修复相对链接
* @param m3u8_text m3u8原始文本里面是最末级的只含ts片段的不支持嵌套m3u8链接
* @param m3u8_url m3u8原始地址
* @param ad_remove 正则表达式如: reg:/video/adjump(.*?)ts
* @returns {string|DocumentFragment|*|string}
*/
function fixAdM3u8(m3u8_text, m3u8_url, ad_remove) {
if ((!m3u8_text && !m3u8_url) || (!m3u8_text && m3u8_url && !m3u8_url.startsWith('http'))) {
return ''
}
if (!m3u8_text) {
log('m3u8_url:' + m3u8_url);
m3u8_text = request(m3u8_url);
}
log('len(m3u8_text):' + m3u8_text.length);
if (!ad_remove) {
return m3u8_text
}
if (ad_remove.startsWith('reg:')) {
ad_remove = ad_remove.slice(4)
} else if (ad_remove.startsWith('js:')) {
ad_remove = ad_remove.slice(3)
}
let m3u8_start = m3u8_text.slice(0, m3u8_text.indexOf('#EXTINF')).trim();
let m3u8_body = m3u8_text.slice(m3u8_text.indexOf('#EXTINF'), m3u8_text.indexOf('#EXT-X-ENDLIST')).trim();
let m3u8_end = m3u8_text.slice(m3u8_text.indexOf('#EXT-X-ENDLIST')).trim();
let murls = [];
let m3_body_list = m3u8_body.split('\n');
let m3_len = m3_body_list.length;
let i = 0;
while (i < m3_len) {
let mi = m3_body_list[i];
let mi_1 = m3_body_list[i + 1];
if (mi.startsWith('#EXTINF')) {
murls.push([mi, mi_1].join('&'));
i += 2
} else if (mi.startsWith('#EXT-X-DISCONTINUITY')) {
let mi_2 = m3_body_list[i + 2];
murls.push([mi, mi_1, mi_2].join('&'));
i += 3
} else {
break;
}
}
let new_m3u8_body = [];
for (let murl of murls) {
if (ad_remove && new RegExp(ad_remove).test(murl)) {
} else {
let murl_list = murl.split('&');
if (!murl_list[murl_list.length - 1].startsWith('http') && m3u8_url.startsWith('http')) {
murl_list[murl_list.length - 1] = urljoin(m3u8_url, murl_list[murl_list.length - 1]);
}
murl_list.forEach((it) => {
new_m3u8_body.push(it);
});
}
}
new_m3u8_body = new_m3u8_body.join('\n').trim();
m3u8_text = [m3u8_start, new_m3u8_body, m3u8_end].join('\n').trim();
return m3u8_text
}
/**
* 智能对比去除广告支持嵌套m3u8只需要传入播放地址
* @param m3u8_url m3u8播放地址
* @returns {string}
*/
function fixAdM3u8Ai(m3u8_url) {
let ts = new Date().getTime();
function b(s1, s2) {
let i = 0;
while (i < s1.length) {
if (s1[i] !== s2[i]) {
break
}
i++
}
return i;
}
function reverseString(str) {
return str.split('').reverse().join('');
}
//log('播放的地址:' + m3u8_url);
let m3u8 = request(m3u8_url);
//log('m3u8处理前:' + m3u8);
m3u8 = m3u8.trim().split('\n').map(it => it.startsWith('#') ? it : urljoin(m3u8_url, it)).join('\n');
//log('m3u8处理后:============:' + m3u8);
// 获取嵌套m3u8地址
let last_url = m3u8.split('\n').slice(-1)[0];
if (last_url.includes('.m3u8') && last_url !== m3u8_url) {
m3u8_url = last_url;
//log('嵌套的m3u8_url:' + m3u8_url);
m3u8 = request(m3u8_url);
}
//log('----处理有广告的地址----');
let s = m3u8.trim().split('\n').filter(it => it.trim()).join('\n');
let ss = s.split('\n')
//找出第一条播放地址
let firststr = ss.find(x => !x.startsWith('#'));
let maxl = 0;//最大相同字符
let firststrlen = firststr.length;
//log('字符串长度:' + firststrlen);
let ml = Math.round(ss.length / 2).toString().length;//取数据的长度的位数
//log('数据条数的长度:' + ml);
//找出最后一条播放地址
let laststr = ss.toReversed().find((x) => {
if (!x.startsWith('#')) {
let k = b(reverseString(firststr), reverseString(x));
maxl = b(firststr, x);
if (firststrlen - maxl <= ml + k) {
return true
}
}
return false
});
log('最后一条切片:' + laststr);
//log('最小相同字符长度:' + maxl);
let ad_urls = [];
for (let i = 0; i < ss.length; i++) {
let s = ss[i];
if (!s.startsWith('#')) {
if (b(firststr, s) < maxl) {
ad_urls.push(s); // 广告地址加入列表
ss.splice(i - 1, 2);
i = i - 2;
} else {
ss[i] = urljoin(m3u8_url, s);
}
} else {
ss[i] = s.replace(/URI=\"(.*)\"/, 'URI=\"' + urljoin(m3u8_url, '$1') + '\"');
}
}
log('处理的m3u8地址:' + m3u8_url);
log('----广告地址----');
log(ad_urls);
m3u8 = ss.join('\n');
//log('处理完成');
log('处理耗时:' + (new Date().getTime() - ts).toString());
return m3u8
}
/**
* 强制正序算法
* @param lists 待正序列表
@ -639,7 +824,7 @@ function pd2(html,parse,uri){
}
if(DOM_CHECK_ATTR.test(parse) && !SPECIAL_URL.test(ret)){
if(/http/.test(ret)){
ret = ret.substr(ret.indexOf('http'));
ret = ret.slice(ret.indexOf('http'));
}else{
ret = urljoin(MY_URL,ret)
}
@ -1009,6 +1194,9 @@ function request(url,obj,ocr_flag){
obj.buffer = 2;
delete obj.toBase64
}
if(obj.redirect===false){
obj.redirect = 0;
}
console.log(JSON.stringify(obj.headers));
// console.log('request:'+url+' obj:'+JSON.stringify(obj));
console.log('request:'+url+`|method:${obj.method||'GET'}|body:${obj.body||''}`);
@ -1135,47 +1323,77 @@ function homeParse(homeObj) {
}
if (homeObj.class_parse) {
let p = homeObj.class_parse.split(';');
let _ps = parseTags.getParse(p[0]);
_pdfa = _ps.pdfa;
_pdfh = _ps.pdfh;
_pd = _ps.pd;
MY_URL = rule.url;
if (p.length >= 3) { // 可以不写正则
try {
let html = getHtml(homeObj.MY_URL);
if (html) {
homeHtmlCache = html;
let list = _pdfa(html, p[0]);
if (list && list.length > 0) {
list.forEach((it,idex) => {
try {
let name = _pdfh(it, p[1]);
if (homeObj.cate_exclude && (new RegExp(homeObj.cate_exclude).test(name))) {
return;
}
// let url = pdfh(it, p[2]);
let url = _pd(it, p[2]);
if (p.length > 3 && p[3]) {
let exp = new RegExp(p[3]);
url = url.match(exp)[1];
}
if(homeObj.class_parse.startsWith('js:')) {
var input = homeObj.MY_URL;
try {
eval(homeObj.class_parse.replace('js:', ''));
if (Array.isArray(input)) {
classes = input;
}
}catch(e){
log('通过js动态获取分类发生了错误:'+e.message);
}
}else {
let p = homeObj.class_parse.split(';');
let p0 = p[0];
let _ps = parseTags.getParse(p0);
let is_json = p0.startsWith('json:');
_pdfa = _ps.pdfa;
_pdfh = _ps.pdfh;
_pd = _ps.pd;
MY_URL = rule.url;
if(is_json){
try {
let cms_cate_url = homeObj.MY_URL.replace('ac=detail','ac=list');
let html = getHtml(cms_cate_url);
if (html) {
if(cms_cate_url === homeObj.MY_URL){
homeHtmlCache = html;
}
let list = _pdfa(html, p0.replace('json:',''));
if (list && list.length > 0) {
classes = list;
}
}
} catch (e) {
console.log(e.message);
}
} else if(p.length >= 3 && !is_json) { // 可以不写正则
try {
let html = getHtml(homeObj.MY_URL);
if (html) {
homeHtmlCache = html;
let list = _pdfa(html, p0);
if (list && list.length > 0) {
list.forEach((it, idex) => {
try {
let name = _pdfh(it, p[1]);
if (homeObj.cate_exclude && (new RegExp(homeObj.cate_exclude).test(name))) {
return;
}
// let url = pdfh(it, p[2]);
let url = _pd(it, p[2]);
if (p.length > 3 && p[3]) {
let exp = new RegExp(p[3]);
url = url.match(exp)[1];
}
classes.push({
'type_id': url.trim(),
'type_name': name.trim()
});
} catch (e) {
console.log(`分类列表定位第${idex}个元素正常报错:${e.message}`);
}
});
}
}
} catch (e) {
console.log(e.message);
}
classes.push({
'type_id': url.trim(),
'type_name': name.trim()
});
} catch (e) {
console.log(`分类列表定位第${idex}个元素正常报错:${e.message}`);
}
});
}
}
} catch (e) {
console.log(e.message);
}
}
}
}
}
// 排除分类
classes = classes.filter(it=>!homeObj.cate_exclude || !(new RegExp(homeObj.cate_exclude).test(it.type_name)));
@ -1375,6 +1593,15 @@ function homeVodParse(homeVodObj){
let t2 = (new Date()).getTime();
console.log('加载首页推荐耗时:'+(t2-t1)+'毫秒');
// console.log(JSON.stringify(d));
if(rule.图片替换 && rule.图片替换.includes('=>')){
let replace_from = rule.图片替换.split('=>')[0];
let replace_to = rule.图片替换.split('=>')[1];
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
it.vod_pic = it.vod_pic.replace(replace_from,replace_to);
}
});
}
if(rule.图片来源){
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
@ -1510,6 +1737,15 @@ function categoryParse(cateObj) {
console.log(e.message);
}
}
if(rule.图片替换 && rule.图片替换.includes('=>')){
let replace_from = rule.图片替换.split('=>')[0];
let replace_to = rule.图片替换.split('=>')[1];
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
it.vod_pic = it.vod_pic.replace(replace_from,replace_to);
}
});
}
if(rule.图片来源){
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
@ -1702,6 +1938,15 @@ function searchParse(searchObj) {
return '{}'
}
}
if(rule.图片替换 && rule.图片替换.includes('=>')){
let replace_from = rule.图片替换.split('=>')[0];
let replace_to = rule.图片替换.split('=>')[1];
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
it.vod_pic = it.vod_pic.replace(replace_from,replace_to);
}
});
}
if(rule.图片来源){
d.forEach(it=>{
if(it.vod_pic&&it.vod_pic.startsWith('http')){
@ -1867,6 +2112,9 @@ function detailParse(detailObj){
let new_map = {};
for(let v of vHeader){
let v_title = _pdfh(v,tab_text).trim();
if(!v_title){
v_title = '线路空'
}
console.log(v_title);
if(tab_exclude&& (new RegExp(tab_exclude)).test(v_title)){
continue;
@ -1959,6 +2207,11 @@ function detailParse(detailObj){
}
vod.vod_play_url = vod_play_url;
}
if(rule.图片替换 && rule.图片替换.includes('=>')){
let replace_from = rule.图片替换.split('=>')[0];
let replace_to = rule.图片替换.split('=>')[1];
vod.vod_pic = vod.vod_pic.replace(replace_from,replace_to);
}
if(rule.图片来源 && vod.vod_pic && vod.vod_pic.startsWith('http')){
vod.vod_pic = vod.vod_pic + rule.图片来源;
}
@ -2058,6 +2311,7 @@ function tellIsJx(url){
function playParse(playObj){
fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
MY_URL = playObj.url;
var MY_FLAG = playObj.flag;
if(!/http/.test(MY_URL)){
try {
MY_URL = base64Decode(MY_URL);
@ -2065,9 +2319,11 @@ function playParse(playObj){
}
MY_URL = decodeURIComponent(MY_URL);
var input = MY_URL;//注入给免嗅js
var flag = MY_FLAG;//注入播放线路名称给免嗅js
let common_play = {
parse:1,
url:input,
flag:flag,
// url:urlencode(input),
jx:tellIsJx(input)
};
@ -2233,6 +2489,7 @@ function init(ext) {
rule.detailUrl = rule.detailUrl||'';
rule.searchUrl = rule.searchUrl||'';
rule.homeUrl = rule.host&&rule.homeUrl?urljoin(rule.host,rule.homeUrl):(rule.homeUrl||rule.host);
rule.homeUrl = cheerio.jinja2(rule.homeUrl,{rule:rule});
rule.detailUrl = rule.host&&rule.detailUrl?urljoin(rule.host,rule.detailUrl):rule.detailUrl;
rule.二级访问前 = rule.二级访问前||'';
if(rule.url.includes('[')&&rule.url.includes(']')){
@ -2254,6 +2511,7 @@ function init(ext) {
rule.encoding = rule.编码||rule.encoding||'utf-8';
rule.search_encoding = rule.搜索编码||rule.search_encoding||'';
rule.图片来源 = rule.图片来源||'';
rule.图片替换 = rule.图片替换||'';
rule.play_json = rule.hasOwnProperty('play_json')?rule.play_json:[];
rule.pagecount = rule.hasOwnProperty('pagecount')?rule.pagecount:{};
rule.proxy_rule = rule.hasOwnProperty('proxy_rule')?rule.proxy_rule:'';

File diff suppressed because one or more lines are too long

265
JN/dr_py/libs/jsencrypt.js Normal file

File diff suppressed because one or more lines are too long