mirror of
https://github.com/qist/tvbox.git
synced 2025-02-02 10:14:50 +08:00
Delete lib directory
This commit is contained in:
parent
d1d79b3877
commit
87f11a3816
819
lib/alist.js
819
lib/alist.js
@ -1,819 +0,0 @@
|
||||
// import _ from 'https://underscorejs.org/underscore-esm-min.js'
|
||||
// import {distance} from 'https://unpkg.com/fastest-levenshtein@1.0.16/esm/mod.js'
|
||||
import {distance} from './mod.js'
|
||||
import {sortListByCN} from './sortName.js'
|
||||
|
||||
/**
|
||||
* alist js
|
||||
* 配置设置 {"key":"Alist","name":"Alist","type":3,"api":"http://xxx.com/alist.js","searchable":0,"quickSearch":0,"filterable":0,"ext":"http://xxx.com/alist.json"}
|
||||
* alist.json [{
|
||||
name:'名称',
|
||||
server:'地址',
|
||||
startPage:'/', //启动文件夹
|
||||
showAll: false , //是否显示全部文件,默认false只显示 音视频和文件夹
|
||||
search: true, // 启用小雅的搜索,搜索只会搜第一个开启此开关的磁盘
|
||||
params:{ //对应文件夹参数 如设置对应文件夹的密码
|
||||
'/abc':{ password : '123' },
|
||||
'/abc/abc':{ password : '123' },
|
||||
}
|
||||
}]
|
||||
* 提示 想要加载文件夹里面全部视频到详情(看剧可以自动播放下一集支持历史记录)
|
||||
* 需要改软件才能支持,,建议长按文件夹时添加判断 tag == folder 时跳转 DetailActivity
|
||||
*/
|
||||
String.prototype.rstrip = function (chars) {
|
||||
let regex = new RegExp(chars + "$");
|
||||
return this.replace(regex, "");
|
||||
};
|
||||
var showMode = 'single';
|
||||
var searchDriver = '';
|
||||
var limit_search_show = 200;
|
||||
var search_type = '';
|
||||
var detail_order = 'name';
|
||||
var playRaw = 1; // 播放直链获取,默认0直接拼接/d 填1可以获取阿里oss链接。注意,有时效性
|
||||
const request_timeout = 5000;
|
||||
const VERSION = 'alist v2/v3 20221223';
|
||||
const UA = 'Mozilla/5.0'; //默认请求ua
|
||||
/**
|
||||
* 打印日志
|
||||
* @param any 任意变量
|
||||
*/
|
||||
function print(any){
|
||||
any = any||'';
|
||||
if(typeof(any)=='object'&&Object.keys(any).length>0){
|
||||
try {
|
||||
any = JSON.stringify(any);
|
||||
console.log(any);
|
||||
}catch (e) {
|
||||
// console.log('print:'+e.message);
|
||||
console.log(typeof(any)+':'+any.length);
|
||||
}
|
||||
}else if(typeof(any)=='object'&&Object.keys(any).length<1){
|
||||
console.log('null object');
|
||||
}else{
|
||||
console.log(any);
|
||||
}
|
||||
}
|
||||
|
||||
/*** js自封装的方法 ***/
|
||||
|
||||
/**
|
||||
* 获取链接的host(带http协议的完整链接)
|
||||
* @param url 任意一个正常完整的Url,自动提取根
|
||||
* @returns {string}
|
||||
*/
|
||||
function getHome(url){
|
||||
if(!url){
|
||||
return ''
|
||||
}
|
||||
let tmp = url.split('//');
|
||||
url = tmp[0] + '//' + tmp[1].split('/')[0];
|
||||
try {
|
||||
url = decodeURIComponent(url);
|
||||
}catch (e) {}
|
||||
return url
|
||||
}
|
||||
|
||||
const http = function (url, options = {}) {
|
||||
if(options.method ==='POST' && options.data){
|
||||
options.body = JSON.stringify(options.data);
|
||||
options.headers = Object.assign({'content-type':'application/json'}, options.headers);
|
||||
}
|
||||
options.timeout = request_timeout;
|
||||
if(!options.headers){
|
||||
options.headers = {};
|
||||
}
|
||||
let keys = Object.keys(options.headers).map(it=>it.toLowerCase());
|
||||
if(!keys.includes('referer')){
|
||||
options.headers['Referer'] = getHome(url);
|
||||
}
|
||||
if(!keys.includes('user-agent')){
|
||||
options.headers['User-Agent'] = UA;
|
||||
}
|
||||
console.log(JSON.stringify(options.headers));
|
||||
try {
|
||||
const res = req(url, options);
|
||||
// if(options.headers['Authorization']){
|
||||
// console.log(res.content);
|
||||
// }
|
||||
res.json = () => res&&res.content ? JSON.parse(res.content) : null;
|
||||
res.text = () => res&&res.content ? res.content:'';
|
||||
return res
|
||||
}catch (e) {
|
||||
return {
|
||||
json() {
|
||||
return null
|
||||
}, text() {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
["get", "post"].forEach(method => {
|
||||
http[method] = function (url, options = {}) {
|
||||
return http(url, Object.assign(options, {method: method.toUpperCase()}));
|
||||
}
|
||||
});
|
||||
|
||||
const __drives = {};
|
||||
|
||||
function isMedia(file){
|
||||
return /\.(dff|dsf|mp3|aac|wav|wma|cda|flac|m4a|mid|mka|mp2|mpa|mpc|ape|ofr|ogg|ra|wv|tta|ac3|dts|tak|webm|wmv|mpeg|mov|ram|swf|mp4|avi|rm|rmvb|flv|mpg|mkv|m3u8|ts|3gp|asf)$/.test(file.toLowerCase());
|
||||
}
|
||||
|
||||
function get_drives_path(tid) {
|
||||
const index = tid.indexOf('$');
|
||||
const name = tid.substring(0, index);
|
||||
const path = tid.substring(index + 1);
|
||||
return { drives: get_drives(name), path };
|
||||
}
|
||||
|
||||
function get_drives(name) {
|
||||
const { settings, api, server,headers } = __drives[name];
|
||||
if (settings.v3 == null) { //获取 设置
|
||||
settings.v3 = false;
|
||||
const data = http.get(server + '/api/public/settings',{headers:headers}).json().data;
|
||||
if (Array.isArray(data)) {
|
||||
settings.title = data.find(x => x.key === 'title')?.value;
|
||||
settings.v3 = false;
|
||||
settings.version = data.find(x => x.key === 'version')?.value;
|
||||
settings.enableSearch = data.find(x => x.key === 'enable search')?.value === 'true';
|
||||
} else {
|
||||
settings.title = data.title;
|
||||
settings.v3 = true;
|
||||
settings.version = data.version;
|
||||
settings.enableSearch = false; //v3 没有找到 搜索配置
|
||||
}
|
||||
//不同版本 接口不一样
|
||||
api.path = settings.v3 ? '/api/fs/list' : '/api/public/path';
|
||||
api.file = settings.v3 ? '/api/fs/get' : '/api/public/path';
|
||||
api.search = settings.v3 ? '/api/public/search' : '/api/public/search';
|
||||
}
|
||||
return __drives[name]
|
||||
}
|
||||
|
||||
function init(ext) {
|
||||
console.log("当前版本号:"+VERSION);
|
||||
let data;
|
||||
if (typeof ext == 'object'){
|
||||
data = ext;
|
||||
print('alist ext:object');
|
||||
} else if (typeof ext == 'string') {
|
||||
if (ext.startsWith('http')) {
|
||||
let alist_data = ext.split(';');
|
||||
let alist_data_url = alist_data[0];
|
||||
limit_search_show = alist_data.length>1?Number(alist_data[1])||limit_search_show:limit_search_show;
|
||||
search_type = alist_data.length>2?alist_data[2]:search_type;
|
||||
print(alist_data_url);
|
||||
data = http.get(alist_data_url).json(); // .map(it=>{it.name='🙋丫仙女';return it})
|
||||
} else {
|
||||
print('alist ext:json string');
|
||||
data = JSON.parse(ext);
|
||||
}
|
||||
}
|
||||
|
||||
// print(data); // 测试证明壳子标题支持emoji,是http请求源码不支持emoji
|
||||
let drives = [];
|
||||
if(Array.isArray(data) && data.length > 0 && data[0].hasOwnProperty('server') && data[0].hasOwnProperty('name')){
|
||||
drives = data;
|
||||
}else if(!Array.isArray(data)&&data.hasOwnProperty('drives')&&Array.isArray(data.drives)){
|
||||
drives = data.drives.filter(it=>(it.type&&it.type==='alist')||!it.type);
|
||||
}
|
||||
print(drives);
|
||||
searchDriver = (drives.find(x=>x.search)||{}).name||'';
|
||||
if(!searchDriver && drives.length > 0){
|
||||
searchDriver = drives[0].name;
|
||||
}
|
||||
print(searchDriver);
|
||||
drives.forEach(item => {
|
||||
let _path_param = [];
|
||||
if(item.params){
|
||||
_path_param = Object.keys(item.params);
|
||||
// 升序排列
|
||||
_path_param.sort((a,b)=>(a.length-b.length));
|
||||
}
|
||||
if(item.password){
|
||||
let pwdObj = {
|
||||
password: item.password
|
||||
};
|
||||
if(!item.params){
|
||||
item.params = {'/':pwdObj};
|
||||
}else{
|
||||
item.params['/'] = pwdObj;
|
||||
}
|
||||
_path_param.unshift('/');
|
||||
}
|
||||
__drives[item.name] = {
|
||||
name: item.name,
|
||||
server: item.server.endsWith("/") ? item.server.rstrip("/") : item.server,
|
||||
startPage: item.startPage || '/', //首页
|
||||
showAll: item.showAll === true, //默认只显示 视频和文件夹,如果想显示全部 showAll 设置true
|
||||
search: !!item.search, //是否支持搜索,只有小丫的可以,多个可搜索只取最前面的一个
|
||||
params: item.params || {},
|
||||
_path_param: _path_param,
|
||||
settings: {},
|
||||
api: {},
|
||||
headers:item.headers||{},
|
||||
getParams(path) {
|
||||
const key = this._path_param.find(x => path.startsWith(x));
|
||||
return Object.assign({}, this.params[key], { path });
|
||||
},
|
||||
getPath(path) {
|
||||
const res = http.post(this.server + this.api.path, { data: this.getParams(path),headers:this.headers }).json();
|
||||
// console.log(res);
|
||||
try {
|
||||
return this.settings.v3 ? res.data.content : res.data.files
|
||||
}catch (e) {
|
||||
console.log(`getPath发生错误:${e.message}`);
|
||||
console.log(JSON.stringify(res));
|
||||
return [{name:'error',value:JSON.stringify(res)}]
|
||||
}
|
||||
},
|
||||
getFile(path) {
|
||||
let raw_url = this.server+'/d'+path;
|
||||
raw_url = encodeURI(raw_url);
|
||||
let data = {raw_url:raw_url,raw_url1:raw_url};
|
||||
if(playRaw===1){
|
||||
try {
|
||||
const res = http.post(this.server + this.api.file, { data: this.getParams(path),headers:this.headers }).json();
|
||||
data = this.settings.v3 ? res.data : res.data.files[0];
|
||||
if (!this.settings.v3) {
|
||||
data.raw_url = data.url; //v2 的url和v3不一样
|
||||
}
|
||||
data.raw_url1 = raw_url;
|
||||
return data
|
||||
}catch (e) {
|
||||
return data
|
||||
}
|
||||
}else{
|
||||
return data
|
||||
}
|
||||
},
|
||||
isFolder(data) { return data.type === 1 },
|
||||
isVideo(data) { //判断是否是 视频文件
|
||||
// return this.settings.v3 ? data.type === 2 : data.type === 3
|
||||
// 增加音乐识别 视频,其他,音频
|
||||
return this.settings.v3 ? (data.type === 2||data.type===0||data.type===3) : (data.type === 3||data.type===0||data.type === 4)
|
||||
},
|
||||
is_subt(data) {
|
||||
if (data.type === 1) {
|
||||
return false;
|
||||
}
|
||||
const ext = /\.(srt|ass|scc|stl|ttml)$/; // [".srt", ".ass", ".scc", ".stl", ".ttml"];
|
||||
// return ext.some(x => data.name.endsWith(x));
|
||||
return ext.test(data.name);
|
||||
},
|
||||
getPic(data) {
|
||||
let pic = this.settings.v3 ? data.thumb : data.thumbnail;
|
||||
return pic || (this.isFolder(data) ? "http://img1.3png.com/281e284a670865a71d91515866552b5f172b.png" : '');
|
||||
},
|
||||
getTime(data,isStandard) {
|
||||
isStandard = isStandard||false;
|
||||
try {
|
||||
let tTime = data.updated_at || data.time_str || data.modified || "";
|
||||
let date = '';
|
||||
if(tTime){
|
||||
tTime = tTime.split("T");
|
||||
date = tTime[0];
|
||||
if(isStandard){
|
||||
date = date.replace(/-/g,"/");
|
||||
}
|
||||
tTime = tTime[1].split(/Z|\./);
|
||||
date += " " + tTime[0];
|
||||
}
|
||||
return date;
|
||||
}catch (e) {
|
||||
// print(e.message);
|
||||
// print(data);
|
||||
return ''
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
);
|
||||
print('init执行完毕');
|
||||
}
|
||||
|
||||
function home(filter) {
|
||||
let classes = Object.keys(__drives).map(key => ({
|
||||
type_id: `${key}$${__drives[key].startPage}`,
|
||||
type_name: key,
|
||||
type_flag: '1',
|
||||
}));
|
||||
let filter_dict = {};
|
||||
let filters = [{'key': 'order', 'name': '排序', 'value': [{'n': '名称⬆️', 'v': 'vod_name_asc'}, {'n': '名称⬇️', 'v': 'vod_name_desc'},
|
||||
{'n': '中英⬆️', 'v': 'vod_cn_asc'}, {'n': '中英⬇️', 'v': 'vod_cn_desc'},
|
||||
{'n': '时间⬆️', 'v': 'vod_time_asc'}, {'n': '时间⬇️', 'v': 'vod_time_desc'},
|
||||
{'n': '大小⬆️', 'v': 'vod_size_asc'}, {'n': '大小⬇️', 'v': 'vod_size_desc'},{'n': '无', 'v': 'none'}]},
|
||||
{'key': 'show', 'name': '播放展示', 'value': [{'n': '单集', 'v': 'single'},{'n': '全集', 'v': 'all'}]}
|
||||
];
|
||||
classes.forEach(it=>{
|
||||
filter_dict[it.type_id] = filters;
|
||||
});
|
||||
print("----home----");
|
||||
print(classes);
|
||||
return JSON.stringify({ 'class': classes,'filters': filter_dict});
|
||||
}
|
||||
|
||||
function homeVod(params) {
|
||||
let _post_data = {"pageNum":0,"pageSize":100};
|
||||
let _post_url = 'https://pbaccess.video.qq.com/trpc.videosearch.hot_rank.HotRankServantHttp/HotRankHttp';
|
||||
let data = http.post(_post_url,{ data: _post_data }).json();
|
||||
let _list = [];
|
||||
try {
|
||||
data = data['data']['navItemList'][0]['hotRankResult']['rankItemList'];
|
||||
// print(data);
|
||||
data.forEach(it=>{
|
||||
_list.push({
|
||||
vod_name:it.title,
|
||||
vod_id:'msearch:'+it.title,
|
||||
vod_pic:'https://avatars.githubusercontent.com/u/97389433?s=120&v=4',
|
||||
vod_remarks:it.changeOrder,
|
||||
});
|
||||
});
|
||||
}catch (e) {
|
||||
print('Alist获取首页推荐发送错误:'+e.message);
|
||||
}
|
||||
return JSON.stringify({ 'list': _list });
|
||||
}
|
||||
|
||||
function category(tid, pg, filter, extend) {
|
||||
let orid = tid.replace(/#all#|#search#/g,'');
|
||||
let { drives, path } = get_drives_path(orid);
|
||||
const id = orid.endsWith('/') ? orid : orid + '/';
|
||||
const list = drives.getPath(path);
|
||||
let subList = [];
|
||||
let vodFiles = [];
|
||||
let allList = [];
|
||||
let fl = filter?extend:{};
|
||||
if(fl.show){
|
||||
showMode = fl.show;
|
||||
}
|
||||
list.forEach(item => {
|
||||
if(item.name!=='error') {
|
||||
if (drives.is_subt(item)) {
|
||||
subList.push(item.name);
|
||||
}
|
||||
if (!drives.showAll && !drives.isFolder(item) && !drives.isVideo(item)) {
|
||||
return //只显示视频文件和文件夹
|
||||
}
|
||||
let vod_time = drives.getTime(item);
|
||||
let vod_size = get_size(item.size);
|
||||
let remark = vod_time.split(' ')[0].substr(3) + '\t' + vod_size;
|
||||
let vod_id = id + item.name + (drives.isFolder(item) ? '/' : '');
|
||||
if (showMode === 'all') {
|
||||
vod_id += '#all#';
|
||||
}
|
||||
print(vod_id);
|
||||
const vod = {
|
||||
'vod_id': vod_id,
|
||||
'vod_name': item.name.replaceAll("$", "").replaceAll("#", ""),
|
||||
'vod_pic': drives.getPic(item),
|
||||
'vod_time': vod_time,
|
||||
'vod_size': item.size,
|
||||
'vod_tag': drives.isFolder(item) ? 'folder' : 'file',
|
||||
'vod_remarks': drives.isFolder(item) ? remark + ' 文件夹' : remark
|
||||
};
|
||||
if (drives.isVideo(item)) {
|
||||
vodFiles.push(vod);
|
||||
}
|
||||
allList.push(vod);
|
||||
}else{
|
||||
console.log(item);
|
||||
const vod = {
|
||||
vod_name: item.value,
|
||||
vod_id: 'no_data',
|
||||
vod_remarks: '不要点,会崩的',
|
||||
vod_pic: 'https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/404.jpg'
|
||||
}
|
||||
allList.push(vod);
|
||||
}
|
||||
});
|
||||
|
||||
if (vodFiles.length === 1 && subList.length > 0) { //只有一个视频 一个或者多个字幕 取相似度最高的
|
||||
// let sub = subList.length === 1 ? subList[0] : _.chain(allList).sortBy(x => (x.includes('chs') ? 100 : 0) + levenshteinDistance(x, vodFiles[0].vod_name)).last().value();
|
||||
let sub; // 字幕文件名称
|
||||
if(subList.length === 1){
|
||||
sub = subList[0];
|
||||
}else {
|
||||
let subs = JSON.parse(JSON.stringify(subList));
|
||||
subs.sort((a,b)=>{
|
||||
// chs是简体中文字幕
|
||||
let a_similar = (a.includes('chs') ? 100 : 0) + levenshteinDistance(a, vodFiles[0].vod_name);
|
||||
let b_similar = (b.includes('chs') ? 100 : 0) + levenshteinDistance(b, vodFiles[0].vod_name);
|
||||
if(a_similar>b_similar) { // 按相似度正序排列
|
||||
return 1;
|
||||
}else{ //否则,位置不变
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
sub = subs.slice(-1)[0];
|
||||
}
|
||||
vodFiles[0].vod_id += "@@@" + sub;
|
||||
// vodFiles[0].vod_remarks += " 有字幕";
|
||||
vodFiles[0].vod_remarks += "🏷️";
|
||||
} else {
|
||||
vodFiles.forEach(item => {
|
||||
const lh = 0;
|
||||
let sub;
|
||||
subList.forEach(s => {
|
||||
//编辑距离相似度
|
||||
const l = levenshteinDistance(s, item.vod_name);
|
||||
if (l > 60 && l > lh) {
|
||||
sub = s;
|
||||
}
|
||||
});
|
||||
if (sub) {
|
||||
item.vod_id += "@@@" + sub;
|
||||
// item.vod_remarks += " 有字幕";
|
||||
item.vod_remarks += "🏷️";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(fl.order){
|
||||
// print(fl.order);
|
||||
let key = fl.order.split('_').slice(0,-1).join('_');
|
||||
let order = fl.order.split('_').slice(-1)[0];
|
||||
print(`排序key:${key},排序order:${order}`);
|
||||
if(key.includes('name')){
|
||||
detail_order = 'name';
|
||||
allList = sortListByName(allList,key,order);
|
||||
}else if(key.includes('cn')){
|
||||
detail_order = 'cn';
|
||||
allList = sortListByCN(allList,'vod_name',order);
|
||||
}else if(key.includes('time')){
|
||||
detail_order = 'time';
|
||||
allList = sortListByTime(allList,key,order);
|
||||
}else if(key.includes('size')){
|
||||
detail_order = 'size';
|
||||
allList = sortListBySize(allList,key,order);
|
||||
}else if(fl.order.includes('none')){
|
||||
detail_order = 'none';
|
||||
print('不排序');
|
||||
}
|
||||
}else{
|
||||
// 没传order是其他地方调用的,自动按名称正序排序方便追剧,如果传了none进去就不排序,假装云盘里本身文件顺序是正常的
|
||||
if(detail_order!=='none'){
|
||||
allList = sortListByName(allList,'vod_name','asc');
|
||||
}
|
||||
}
|
||||
|
||||
print("----category----"+`tid:${tid},detail_order:${detail_order},showMode:${showMode}`);
|
||||
// print(allList);
|
||||
return JSON.stringify({
|
||||
'page': 1,
|
||||
'pagecount': 1,
|
||||
'limit': allList.length,
|
||||
'total': allList.length,
|
||||
'list': allList,
|
||||
});
|
||||
}
|
||||
|
||||
function getAll(otid,tid,drives,path){
|
||||
try {
|
||||
const content = category(tid, null, false, null);
|
||||
const isFile = isMedia(otid.replace(/#all#|#search#/g,'').split('@@@')[0]);
|
||||
const { list } = JSON.parse(content);
|
||||
let vod_play_url = [];
|
||||
list.forEach(x => {
|
||||
if (x.vod_tag === 'file'){
|
||||
let vid = x.vod_id.replace(/#all#|#search#/g,'');
|
||||
vod_play_url.push(`${x.vod_name}$${vid.substring(vid.indexOf('$') + 1)}`);
|
||||
}
|
||||
});
|
||||
const pl = path.split("/").filter(it=>it);
|
||||
let vod_name = pl[pl.length - 1] || drives.name;
|
||||
if(vod_name === drives.name){
|
||||
print(pl);
|
||||
}
|
||||
if(otid.includes('#search#')){
|
||||
vod_name+='[搜]';
|
||||
}
|
||||
let vod = {
|
||||
// vod_id: tid,
|
||||
vod_id: otid,
|
||||
vod_name: vod_name,
|
||||
type_name: "文件夹",
|
||||
vod_pic: "https://avatars.githubusercontent.com/u/97389433?s=120&v=4",
|
||||
vod_content: tid,
|
||||
vod_tag: 'folder',
|
||||
vod_play_from: drives.name,
|
||||
vod_play_url: vod_play_url.join('#'),
|
||||
vod_remarks: drives.settings.title,
|
||||
}
|
||||
print("----detail1----");
|
||||
print(vod);
|
||||
return JSON.stringify({ 'list': [vod] });
|
||||
}catch (e) {
|
||||
print(e.message);
|
||||
let list = [{vod_name:'无数据,防无限请求',type_name: "文件夹",vod_id:'no_data',vod_remarks:'不要点,会崩的',vod_pic:'https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/static/img/404.jpg',vod_actor:e.message,vod_director: tid,vod_content: otid}];
|
||||
return JSON.stringify({ 'list': list });
|
||||
}
|
||||
}
|
||||
|
||||
function detail(tid) {
|
||||
let isSearch = tid.includes('#search#');
|
||||
let isAll = tid.includes('#all#');
|
||||
let otid = tid;
|
||||
tid = tid.replace(/#all#|#search#/g,'');
|
||||
let isFile = isMedia(tid.split('@@@')[0]);
|
||||
print(`isFile:${tid}?${isFile}`);
|
||||
let { drives, path } = get_drives_path(tid);
|
||||
print(`drives:${drives},path:${path},`);
|
||||
if (path.endsWith("/")) { //长按文件夹可以 加载里面全部视频到详情
|
||||
return getAll(otid,tid,drives,path);
|
||||
} else {
|
||||
if(isSearch&&!isFile){ // 搜索结果 当前目录获取所有文件
|
||||
return getAll(otid,tid,drives,path);
|
||||
}else if(isAll){ // 上级目录获取所有文件 不管是搜索还是分类,只要不是 搜索到的文件夹,且展示模式为全部,都获取上级目录的所有文件
|
||||
// 是文件就取上级目录
|
||||
let new_tid;
|
||||
if(isFile){
|
||||
new_tid = tid.split('/').slice(0,-1).join('/')+'/';
|
||||
}else{
|
||||
new_tid = tid;
|
||||
}
|
||||
print(`全集模式 tid:${tid}=>tid:${new_tid}`);
|
||||
let { drives, path } = get_drives_path(new_tid);
|
||||
return getAll(otid,new_tid,drives,path);
|
||||
} else if(isFile){ // 单文件进入
|
||||
let paths = path.split("@@@");
|
||||
let vod_name = paths[0].substring(paths[0].lastIndexOf("/") + 1);
|
||||
let vod_title = vod_name;
|
||||
if(otid.includes('#search#')){
|
||||
vod_title+='[搜]';
|
||||
}
|
||||
let vod = {
|
||||
vod_id: otid,
|
||||
vod_name: vod_title,
|
||||
type_name: "文件",
|
||||
vod_pic: "https://avatars.githubusercontent.com/u/97389433?s=120&v=4",
|
||||
vod_content: tid,
|
||||
vod_play_from: drives.name,
|
||||
vod_play_url: vod_name + "$" + path,
|
||||
vod_remarks: drives.settings.title,
|
||||
};
|
||||
print("----detail2----");
|
||||
print(vod);
|
||||
return JSON.stringify({
|
||||
'list': [vod]
|
||||
});
|
||||
}else{
|
||||
return JSON.stringify({
|
||||
'list': []
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function play(flag, id, flags) {
|
||||
const drives = get_drives(flag);
|
||||
const urls = id.split("@@@"); // @@@ 分割前是 相对文件path,分割后是字幕文件
|
||||
let vod = {
|
||||
'parse': 0,
|
||||
'playUrl': '',
|
||||
// 'url': drives.getFile(urls[0]).raw_url+'#.m3u8' // 加 # 没法播放
|
||||
'url': drives.getFile(urls[0]).raw_url
|
||||
};
|
||||
if (urls.length >= 2) {
|
||||
const path = urls[0].substring(0, urls[0].lastIndexOf('/') + 1);
|
||||
vod.subt = drives.getFile(path + urls[1]).raw_url1;
|
||||
}
|
||||
print("----play----");
|
||||
print(vod);
|
||||
return JSON.stringify(vod);
|
||||
}
|
||||
|
||||
function search(wd, quick) {
|
||||
print(__drives);
|
||||
print('可搜索的alist驱动:'+searchDriver);
|
||||
if(!searchDriver||!wd){
|
||||
return JSON.stringify({
|
||||
'list': []
|
||||
});
|
||||
}else{
|
||||
let driver = __drives[searchDriver];
|
||||
wd = wd.split(' ').filter(it=>it.trim()).join('+');
|
||||
print(driver);
|
||||
let surl = driver.server + '/search?box='+wd+'&url=';
|
||||
if(search_type){
|
||||
surl+='&type='+search_type;
|
||||
}
|
||||
print('搜索链接:'+surl);
|
||||
let html = http.get(surl).text();
|
||||
let lists = [];
|
||||
try {
|
||||
lists = pdfa(html,'div&&ul&&a');
|
||||
}catch (e) {}
|
||||
print(`搜索结果数:${lists.length},搜索结果显示数量限制:${limit_search_show}`);
|
||||
let vods = [];
|
||||
let excludeReg = /\.(pdf|epub|mobi|txt|doc|lrc)$/; // 过滤后缀文件
|
||||
let cnt = 0;
|
||||
lists.forEach(it=>{
|
||||
let vhref = pdfh(it,'a&&href');
|
||||
if(vhref){
|
||||
vhref = unescape(vhref);
|
||||
}
|
||||
if(excludeReg.test(vhref)){
|
||||
return; //跳过本次循环
|
||||
}
|
||||
if(cnt < limit_search_show){
|
||||
print(vhref);
|
||||
}
|
||||
cnt ++;
|
||||
let vid = searchDriver+'$'+vhref+'#search#';
|
||||
if(showMode==='all'){
|
||||
vid+='#all#';
|
||||
}
|
||||
vods.push({
|
||||
vod_name:pdfh(it,'a&&Text'),
|
||||
vod_id:vid,
|
||||
vod_tag: isMedia(vhref) ? 'file' : 'folder',
|
||||
vod_pic:'http://img1.3png.com/281e284a670865a71d91515866552b5f172b.png',
|
||||
vod_remarks:searchDriver
|
||||
});
|
||||
});
|
||||
// 截取搜索结果
|
||||
vods = vods.slice(0,limit_search_show);
|
||||
print(vods);
|
||||
return JSON.stringify({
|
||||
'list': vods
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function get_size(sz) {
|
||||
if (sz <= 0) {
|
||||
return "";
|
||||
}
|
||||
let filesize = "";
|
||||
if (sz > 1024 * 1024 * 1024 * 1024.0) {
|
||||
sz /= (1024 * 1024 * 1024 * 1024.0);
|
||||
filesize = "TB";
|
||||
} else if (sz > 1024 * 1024 * 1024.0) {
|
||||
sz /= (1024 * 1024 * 1024.0);
|
||||
filesize = "GB";
|
||||
} else if (sz > 1024 * 1024.0) {
|
||||
sz /= (1024 * 1024.0);
|
||||
filesize = "MB";
|
||||
} else if( sz > 1024.0){
|
||||
sz /= 1024.0;
|
||||
filesize = "KB";
|
||||
}else{
|
||||
filesize = "B";
|
||||
}
|
||||
// 转成字符串
|
||||
let sizeStr = sz.toFixed(2) + filesize,
|
||||
// 获取小数点处的索引
|
||||
index = sizeStr.indexOf("."),
|
||||
// 获取小数点后两位的值
|
||||
dou = sizeStr.substr(index + 1, 2);
|
||||
if (dou === "00") {
|
||||
return sizeStr.substring(0, index) + sizeStr.substr(index + 3, 2);
|
||||
}else{
|
||||
return sizeStr;
|
||||
}
|
||||
}
|
||||
|
||||
// 相似度获取
|
||||
function levenshteinDistance(str1, str2) {
|
||||
return 100 - 100 * distance(str1, str2) / Math.max(str1.length, str2.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自然排序
|
||||
* ["第1集","第10集","第20集","第2集","1","2","10","12","23","01","02"].sort(naturalSort())
|
||||
* @param options {{key,caseSensitive, order: string}}
|
||||
*/
|
||||
function naturalSort(options) {
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
return function (a, b) {
|
||||
if(options.key){
|
||||
a = a[options.key];
|
||||
b = b[options.key];
|
||||
}
|
||||
var EQUAL = 0;
|
||||
var GREATER = (options.order === 'desc' ?
|
||||
-1 :
|
||||
1
|
||||
);
|
||||
var SMALLER = -GREATER;
|
||||
|
||||
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi;
|
||||
var sre = /(^[ ]*|[ ]*$)/g;
|
||||
var dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/;
|
||||
var hre = /^0x[0-9a-f]+$/i;
|
||||
var ore = /^0/;
|
||||
|
||||
var normalize = function normalize(value) {
|
||||
var string = '' + value;
|
||||
return (options.caseSensitive ?
|
||||
string :
|
||||
string.toLowerCase()
|
||||
);
|
||||
};
|
||||
|
||||
// Normalize values to strings
|
||||
var x = normalize(a).replace(sre, '') || '';
|
||||
var y = normalize(b).replace(sre, '') || '';
|
||||
|
||||
// chunk/tokenize
|
||||
var xN = x.replace(re, '\0$1\0').replace(/\0$/, '').replace(/^\0/, '').split('\0');
|
||||
var yN = y.replace(re, '\0$1\0').replace(/\0$/, '').replace(/^\0/, '').split('\0');
|
||||
|
||||
// Return immediately if at least one of the values is empty.
|
||||
if (!x && !y) return EQUAL;
|
||||
if (!x && y) return GREATER;
|
||||
if (x && !y) return SMALLER;
|
||||
|
||||
// numeric, hex or date detection
|
||||
var xD = parseInt(x.match(hre)) || (xN.length != 1 && x.match(dre) && Date.parse(x));
|
||||
var yD = parseInt(y.match(hre)) || xD && y.match(dre) && Date.parse(y) || null;
|
||||
var oFxNcL, oFyNcL;
|
||||
|
||||
// first try and sort Hex codes or Dates
|
||||
if (yD) {
|
||||
if (xD < yD) return SMALLER;
|
||||
else if (xD > yD) return GREATER;
|
||||
}
|
||||
|
||||
// natural sorting through split numeric strings and default strings
|
||||
for (var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
|
||||
|
||||
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
|
||||
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
|
||||
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
||||
|
||||
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
||||
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) return (isNaN(oFxNcL)) ? GREATER : SMALLER;
|
||||
|
||||
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
||||
else if (typeof oFxNcL !== typeof oFyNcL) {
|
||||
oFxNcL += '';
|
||||
oFyNcL += '';
|
||||
}
|
||||
if (oFxNcL < oFyNcL) return SMALLER;
|
||||
if (oFxNcL > oFyNcL) return GREATER;
|
||||
}
|
||||
return EQUAL;
|
||||
};
|
||||
}
|
||||
// 完整名称排序
|
||||
const sortListByName = (vodList,key,order) => {
|
||||
if(!key){
|
||||
return vodList
|
||||
}
|
||||
order = order||'asc'; // 默认正序
|
||||
// 排序键,顺序,区分大小写
|
||||
return vodList.sort(naturalSort({key: key, order: order,caseSensitive:true}))
|
||||
};
|
||||
|
||||
const getTimeInt = (timeStr) => {
|
||||
return (new Date(timeStr)).getTime();
|
||||
};
|
||||
|
||||
// 时间
|
||||
const sortListByTime = (vodList,key,order) => {
|
||||
if (!key) {
|
||||
return vodList
|
||||
}
|
||||
let ASCarr = vodList.sort((a, b) => {
|
||||
a = a[key];
|
||||
b = b[key];
|
||||
return getTimeInt(a) - getTimeInt(b);
|
||||
});
|
||||
if(order==='desc'){
|
||||
ASCarr.reverse();
|
||||
}
|
||||
return ASCarr
|
||||
};
|
||||
|
||||
// 大小
|
||||
const sortListBySize = (vodList,key,order) => {
|
||||
if (!key) {
|
||||
return vodList
|
||||
}
|
||||
let ASCarr = vodList.sort((a, b) => {
|
||||
a = a[key];
|
||||
b = b[key];
|
||||
return (Number(a) || 0) - (Number(b) || 0);
|
||||
});
|
||||
if(order==='desc'){
|
||||
ASCarr.reverse();
|
||||
}
|
||||
return ASCarr
|
||||
};
|
||||
|
||||
// 导出函数对象
|
||||
export default {
|
||||
init: init,
|
||||
home: home,
|
||||
homeVod: homeVod,
|
||||
category: category,
|
||||
detail: detail,
|
||||
play: play,
|
||||
search: search
|
||||
}
|
1
lib/alist.min.js
vendored
1
lib/alist.min.js
vendored
File diff suppressed because one or more lines are too long
1447
lib/drpy-ym.js
1447
lib/drpy-ym.js
File diff suppressed because it is too large
Load Diff
2366
lib/drpy.js
2366
lib/drpy.js
File diff suppressed because it is too large
Load Diff
1
lib/drpy.min.js
vendored
1
lib/drpy.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,4 +0,0 @@
|
||||
import './util.ym.js'
|
||||
import dr from './drpy.min.js'
|
||||
|
||||
__JS_SPIDER__ = dr.DRPY()
|
2096
lib/drpy2-2838.js
2096
lib/drpy2-2838.js
File diff suppressed because it is too large
Load Diff
2246
lib/drpy2.js
2246
lib/drpy2.js
File diff suppressed because it is too large
Load Diff
1
lib/drpy2.min.js
vendored
1
lib/drpy2.min.js
vendored
File diff suppressed because one or more lines are too long
68
lib/gbk.js
68
lib/gbk.js
File diff suppressed because one or more lines are too long
138
lib/mod.js
138
lib/mod.js
@ -1,138 +0,0 @@
|
||||
const peq = new Uint32Array(0x10000);
|
||||
const myers_32 = (a, b) => {
|
||||
const n = a.length;
|
||||
const m = b.length;
|
||||
const lst = 1 << (n - 1);
|
||||
let pv = -1;
|
||||
let mv = 0;
|
||||
let sc = n;
|
||||
let i = n;
|
||||
while (i--) {
|
||||
peq[a.charCodeAt(i)] |= 1 << i;
|
||||
}
|
||||
for (i = 0; i < m; i++) {
|
||||
let eq = peq[b.charCodeAt(i)];
|
||||
const xv = eq | mv;
|
||||
eq |= ((eq & pv) + pv) ^ pv;
|
||||
mv |= ~(eq | pv);
|
||||
pv &= eq;
|
||||
if (mv & lst) {
|
||||
sc++;
|
||||
}
|
||||
if (pv & lst) {
|
||||
sc--;
|
||||
}
|
||||
mv = (mv << 1) | 1;
|
||||
pv = (pv << 1) | ~(xv | mv);
|
||||
mv &= xv;
|
||||
}
|
||||
i = n;
|
||||
while (i--) {
|
||||
peq[a.charCodeAt(i)] = 0;
|
||||
}
|
||||
return sc;
|
||||
};
|
||||
const myers_x = (b, a) => {
|
||||
const n = a.length;
|
||||
const m = b.length;
|
||||
const mhc = [];
|
||||
const phc = [];
|
||||
const hsize = Math.ceil(n / 32);
|
||||
const vsize = Math.ceil(m / 32);
|
||||
for (let i = 0; i < hsize; i++) {
|
||||
phc[i] = -1;
|
||||
mhc[i] = 0;
|
||||
}
|
||||
let j = 0;
|
||||
for (; j < vsize - 1; j++) {
|
||||
let mv = 0;
|
||||
let pv = -1;
|
||||
const start = j * 32;
|
||||
const vlen = Math.min(32, m) + start;
|
||||
for (let k = start; k < vlen; k++) {
|
||||
peq[b.charCodeAt(k)] |= 1 << k;
|
||||
}
|
||||
for (let i = 0; i < n; i++) {
|
||||
const eq = peq[a.charCodeAt(i)];
|
||||
const pb = (phc[(i / 32) | 0] >>> i) & 1;
|
||||
const mb = (mhc[(i / 32) | 0] >>> i) & 1;
|
||||
const xv = eq | mv;
|
||||
const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb;
|
||||
let ph = mv | ~(xh | pv);
|
||||
let mh = pv & xh;
|
||||
if ((ph >>> 31) ^ pb) {
|
||||
phc[(i / 32) | 0] ^= 1 << i;
|
||||
}
|
||||
if ((mh >>> 31) ^ mb) {
|
||||
mhc[(i / 32) | 0] ^= 1 << i;
|
||||
}
|
||||
ph = (ph << 1) | pb;
|
||||
mh = (mh << 1) | mb;
|
||||
pv = mh | ~(xv | ph);
|
||||
mv = ph & xv;
|
||||
}
|
||||
for (let k = start; k < vlen; k++) {
|
||||
peq[b.charCodeAt(k)] = 0;
|
||||
}
|
||||
}
|
||||
let mv = 0;
|
||||
let pv = -1;
|
||||
const start = j * 32;
|
||||
const vlen = Math.min(32, m - start) + start;
|
||||
for (let k = start; k < vlen; k++) {
|
||||
peq[b.charCodeAt(k)] |= 1 << k;
|
||||
}
|
||||
let score = m;
|
||||
for (let i = 0; i < n; i++) {
|
||||
const eq = peq[a.charCodeAt(i)];
|
||||
const pb = (phc[(i / 32) | 0] >>> i) & 1;
|
||||
const mb = (mhc[(i / 32) | 0] >>> i) & 1;
|
||||
const xv = eq | mv;
|
||||
const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb;
|
||||
let ph = mv | ~(xh | pv);
|
||||
let mh = pv & xh;
|
||||
score += (ph >>> (m - 1)) & 1;
|
||||
score -= (mh >>> (m - 1)) & 1;
|
||||
if ((ph >>> 31) ^ pb) {
|
||||
phc[(i / 32) | 0] ^= 1 << i;
|
||||
}
|
||||
if ((mh >>> 31) ^ mb) {
|
||||
mhc[(i / 32) | 0] ^= 1 << i;
|
||||
}
|
||||
ph = (ph << 1) | pb;
|
||||
mh = (mh << 1) | mb;
|
||||
pv = mh | ~(xv | ph);
|
||||
mv = ph & xv;
|
||||
}
|
||||
for (let k = start; k < vlen; k++) {
|
||||
peq[b.charCodeAt(k)] = 0;
|
||||
}
|
||||
return score;
|
||||
};
|
||||
const distance = (a, b) => {
|
||||
if (a.length < b.length) {
|
||||
const tmp = b;
|
||||
b = a;
|
||||
a = tmp;
|
||||
}
|
||||
if (b.length === 0) {
|
||||
return a.length;
|
||||
}
|
||||
if (a.length <= 32) {
|
||||
return myers_32(a, b);
|
||||
}
|
||||
return myers_x(a, b);
|
||||
};
|
||||
const closest = (str, arr) => {
|
||||
let min_distance = Infinity;
|
||||
let min_index = 0;
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const dist = distance(str, arr[i]);
|
||||
if (dist < min_distance) {
|
||||
min_distance = dist;
|
||||
min_index = i;
|
||||
}
|
||||
}
|
||||
return arr[min_index];
|
||||
};
|
||||
export { closest, distance };
|
267
lib/pre.js
267
lib/pre.js
@ -1,267 +0,0 @@
|
||||
var VODS = [];
|
||||
var $ = {};
|
||||
if (!String.prototype.includes) {
|
||||
String.prototype.includes = function (search, start) {
|
||||
|
||||
if (typeof start !== 'number') {
|
||||
start = 0;
|
||||
}
|
||||
|
||||
if (start + search.length > this.length) {
|
||||
return false;
|
||||
} else {
|
||||
return this.indexOf(search, start) !== -1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (!Array.prototype.includes) {
|
||||
Object.defineProperty(Array.prototype, 'includes', {
|
||||
value: function (searchElement, fromIndex) {
|
||||
|
||||
if (this == null) {//this是空或者未定义,抛出错误
|
||||
throw new TypeError('"this" is null or not defined');
|
||||
}
|
||||
|
||||
var o = Object(this);//将this转变成对象
|
||||
var len = o.length >>> 0;//无符号右移0位,获取对象length属性,如果未定义就会变成0
|
||||
|
||||
if (len === 0) {//length为0直接返回false未找到目标值
|
||||
return false;
|
||||
}
|
||||
|
||||
var n = fromIndex | 0;//查找起始索引
|
||||
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);//计算正确起始索引,因为有可能是负值
|
||||
|
||||
while (k < len) {//从起始索引处开始循环
|
||||
if (o[k] === searchElement) {//如果某一位置与寻找目标相等,返回true,找到了
|
||||
return true;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
return false;//未找到,返回false
|
||||
}
|
||||
});
|
||||
}
|
||||
if (typeof String.prototype.startsWith != 'function') {
|
||||
String.prototype.startsWith = function (prefix){
|
||||
return this.slice(0, prefix.length) === prefix;
|
||||
};
|
||||
}
|
||||
if (typeof String.prototype.endsWith != 'function') {
|
||||
String.prototype.endsWith = function(suffix) {
|
||||
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
||||
};
|
||||
}
|
||||
|
||||
Object.assign = function () {
|
||||
var target = arguments[0];
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
};
|
||||
Object.prototype.myValues=function(obj){
|
||||
if(obj ==null) {
|
||||
throw new TypeError("Cannot convert undefined or null to object");
|
||||
}
|
||||
var res=[]
|
||||
for(var k in obj){
|
||||
if(obj.hasOwnProperty(k)){//需判断是否是本身的属性
|
||||
res.push(obj[k]);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
if (typeof Object.prototype.values != 'function') {
|
||||
Object.prototype.values=function(obj){
|
||||
if(obj ==null) {
|
||||
throw new TypeError("Cannot convert undefined or null to object");
|
||||
}
|
||||
var res=[]
|
||||
for(var k in obj){
|
||||
if(obj.hasOwnProperty(k)){//需判断是否是本身的属性
|
||||
res.push(obj[k]);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
Array.prototype.join = function (emoji) {
|
||||
// emoji = emoji||',';
|
||||
emoji = emoji||'';
|
||||
let self = this;
|
||||
let str = "";
|
||||
let i = 0;
|
||||
if (!Array.isArray(self)) {throw String(self)+'is not Array'}
|
||||
if(self.length===0){return ''}
|
||||
if (self.length === 1){return String(self[0])}
|
||||
i = 1;
|
||||
str = this[0];
|
||||
for (; i < self.length; i++) {
|
||||
str += String(emoji)+String(self[i]);
|
||||
}
|
||||
return str;
|
||||
};
|
||||
Array.prototype.append = Array.prototype.push;
|
||||
String.prototype.strip = String.prototype.trim;
|
||||
function 是否正版(vipUrl){
|
||||
let flag = new RegExp('qq\.com|iqiyi\.com|youku\.com|mgtv\.com|bilibili\.com|sohu\.com|ixigua\.com|pptv\.com|miguvideo\.com|le\.com|1905\.com|fun\.tv');
|
||||
return flag.test(vipUrl);
|
||||
}
|
||||
function urlDeal(vipUrl){
|
||||
if(!vipUrl){
|
||||
return ''
|
||||
}
|
||||
if(!是否正版(vipUrl)){
|
||||
return vipUrl
|
||||
}
|
||||
if(!/miguvideo/.test(vipUrl)){
|
||||
vipUrl=vipUrl.split('#')[0].split('?')[0];
|
||||
}
|
||||
return vipUrl
|
||||
}
|
||||
function setResult(d){
|
||||
if(!Array.isArray(d)){
|
||||
return []
|
||||
}
|
||||
d.forEach(function (it){
|
||||
let obj = {
|
||||
vod_id:it.url||'',
|
||||
vod_name: it.title||'',
|
||||
vod_remarks: it.desc||'',
|
||||
vod_content: it.content||'',
|
||||
vod_pic: it.pic_url||it.img||'',
|
||||
};
|
||||
let keys = Object.keys(it);
|
||||
if(keys.includes('tname')){
|
||||
obj.type_name = it.tname||'';
|
||||
}
|
||||
if(keys.includes('tid')){
|
||||
obj.type_id = it.tid||'';
|
||||
}
|
||||
if(keys.includes('year')){
|
||||
obj.vod_year = it.year||'';
|
||||
}
|
||||
if(keys.includes('actor')){
|
||||
obj.vod_actor = it.actor||'';
|
||||
}
|
||||
if(keys.includes('director')){
|
||||
obj.vod_director = it.director||'';
|
||||
}
|
||||
if(keys.includes('area')){
|
||||
obj.vod_area = it.area||'';
|
||||
}
|
||||
VODS.push(obj);
|
||||
});
|
||||
return VODS
|
||||
}
|
||||
function setResult2(res){
|
||||
VODS = res.list||[];
|
||||
return VODS
|
||||
}
|
||||
function setHomeResult(res){
|
||||
if(!res||typeof(res)!=='object'){
|
||||
return []
|
||||
}
|
||||
return setResult(res.list);
|
||||
}
|
||||
// 千万不要用for in 推荐 forEach (for in 会打乱顺序)
|
||||
//猫函数
|
||||
function maoss(jxurl, ref, key) {
|
||||
eval(getCryptoJS());
|
||||
try {
|
||||
var getVideoInfo = function (text) {
|
||||
return CryptoJS.AES.decrypt(text, key, {iv: iv, padding: CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8);
|
||||
};
|
||||
var token_key = key == undefined ? 'dvyYRQlnPRCMdQSe' : key;
|
||||
if (ref) {
|
||||
var html = request(jxurl, {
|
||||
headers: {
|
||||
'Referer': ref
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var html = request(jxurl);
|
||||
}
|
||||
// print(html);
|
||||
if (html.indexOf('&btwaf=') != -1) {
|
||||
html = request(jxurl + '&btwaf' + html.match(/&btwaf(.*?)"/)[1], {
|
||||
headers: {
|
||||
'Referer': ref
|
||||
}
|
||||
})
|
||||
}
|
||||
var token_iv = html.split('_token = "')[1].split('"')[0];
|
||||
var key = CryptoJS.enc.Utf8.parse(token_key);
|
||||
var iv = CryptoJS.enc.Utf8.parse(token_iv);
|
||||
// log("iv:"+iv);
|
||||
// log(html);
|
||||
// print(key);
|
||||
// print(iv);
|
||||
eval(html.match(/var config = {[\s\S]*?}/)[0] + '');
|
||||
// config.url = config.url.replace(/,/g,'');
|
||||
// print(config.url);
|
||||
if (!config.url.startsWith('http')) {
|
||||
//config.url = decodeURIComponent(AES(config.url, key, iv));
|
||||
config.url = CryptoJS.AES.decrypt(config.url, key, {
|
||||
iv: iv,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
}).toString(CryptoJS.enc.Utf8)
|
||||
}
|
||||
return config.url;
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function request(url,obj){
|
||||
// obj = obj||{'user-agent': MOBILE_UA};
|
||||
let new_obj;
|
||||
if(typeof(fetch_params)!=='undefined'){
|
||||
new_obj = obj?Object.assign(fetch_params,obj):fetch_params;
|
||||
}else{
|
||||
new_obj = obj||{}
|
||||
}
|
||||
if(!new_obj||!new_obj.headers){
|
||||
new_obj.headers = {};
|
||||
}
|
||||
if(!new_obj.headers['User-Agent']&&!new_obj.headers['user-agent']){
|
||||
new_obj.headers['User-Agent'] = MOBILE_UA;
|
||||
}
|
||||
// delete new_obj.headers['Referer'];
|
||||
// print(obj);
|
||||
// print(new_obj);
|
||||
if(typeof(fetch)!==undefined){
|
||||
let html = fetch(url,new_obj);
|
||||
if (/\?btwaf=/.test(html)) {//宝塔验证
|
||||
url=url.split('#')[0]+'?btwaf'+html.match(/btwaf(.*?)\"/)[1];
|
||||
log("宝塔验证跳转到:"+url);
|
||||
html = fetch(url, new_obj);
|
||||
}
|
||||
return html
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function rc(url){// 系统已经有require方法了,再覆盖的话无法操作了
|
||||
res = eval(requireObj(url));
|
||||
// print(res);
|
||||
return res;
|
||||
// return eval.call(null, requireObj(url));
|
||||
}
|
||||
|
||||
$.require = rc;
|
||||
|
||||
function urlencode (str) {
|
||||
str = (str + '').toString();
|
||||
|
||||
return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
|
||||
replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
|
||||
}
|
178
lib/sortName.js
178
lib/sortName.js
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
52eb497172f44b498943ac642d62113e
|
301
lib/模板.js
301
lib/模板.js
@ -1,301 +0,0 @@
|
||||
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) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
};
|
||||
}
|
||||
function getMubans() {
|
||||
var mubanDict = { // 模板字典
|
||||
mxpro: {
|
||||
title: '',
|
||||
host: '',
|
||||
// homeUrl:'/',
|
||||
url: '/vodshow/fyclass--------fypage---.html',
|
||||
searchUrl: '/vodsearch/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {//网站的请求头,完整支持所有的,常带ua和cookies
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
// "Cookie": "searchneed=ok"
|
||||
},
|
||||
class_parse: '.navbar-items li:gt(2):lt(8);a&&Text;a&&href;/(\\d+).html',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: '.tab-list.active;a.module-poster-item.module-item;.module-poster-item-title&&Text;.lazyload&&data-original;.module-item-note&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: 'body a.module-poster-item.module-item;a&&title;.lazyload&&data-original;.module-item-note&&Text;a&&href',
|
||||
二级: {
|
||||
"title": "h1&&Text;.module-info-tag&&Text",
|
||||
"img": ".lazyload&&data-original",
|
||||
"desc": ".module-info-item:eq(1)&&Text;.module-info-item:eq(2)&&Text;.module-info-item:eq(3)&&Text",
|
||||
"content": ".module-info-introduction&&Text",
|
||||
"tabs": ".module-tab-item",
|
||||
"lists": ".module-play-list:eq(#id) a"
|
||||
},
|
||||
搜索: 'body .module-item;.module-card-item-title&&Text;.lazyload&&data-original;.module-item-note&&Text;a&&href;.module-info-item-content&&Text',
|
||||
},
|
||||
mxone5: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/show/fyclass--------fypage---.html',
|
||||
searchUrl: '/search/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
class_parse: '.nav-menu-items&&li;a&&Text;a&&href;.*/(.*?).html',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: '.module-list;.module-items&&.module-item;a&&title;img&&data-src;.module-item-text&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: '.module-items .module-item;a&&title;img&&data-src;.module-item-text&&Text;a&&href',
|
||||
二级: {
|
||||
"title": "h1&&Text;.tag-link&&Text",
|
||||
"img": ".module-item-pic&&img&&data-src",
|
||||
"desc": ".video-info-items:eq(0)&&Text;.video-info-items:eq(1)&&Text;.video-info-items:eq(2)&&Text;.video-info-items:eq(3)&&Text",
|
||||
"content": ".vod_content&&Text",
|
||||
"tabs": ".module-tab-item",
|
||||
"lists": ".module-player-list:eq(#id)&&.scroll-content&&a"
|
||||
},
|
||||
搜索: '.module-items .module-search-item;a&&title;img&&data-src;.video-serial&&Text;a&&href',
|
||||
},
|
||||
首图: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/vodshow/fyclass--------fypage---/',
|
||||
searchUrl: '/vodsearch/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {//网站的请求头,完整支持所有的,常带ua和cookies
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
// "Cookie": "searchneed=ok"
|
||||
},
|
||||
class_parse: '.myui-header__menu li.hidden-sm:gt(0):lt(5);a&&Text;a&&href;/(\\d+).html',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: 'ul.myui-vodlist.clearfix;li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: '.myui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
|
||||
二级: {
|
||||
"title": ".myui-content__detail .title&&Text;.myui-content__detail p:eq(-2)&&Text",
|
||||
"img": ".myui-content__thumb .lazyload&&data-original",
|
||||
"desc": ".myui-content__detail p:eq(0)&&Text;.myui-content__detail p:eq(1)&&Text;.myui-content__detail p:eq(2)&&Text",
|
||||
"content": ".content&&Text",
|
||||
"tabs": ".nav-tabs:eq(0) li",
|
||||
"lists": ".myui-content__list:eq(#id) li"
|
||||
},
|
||||
搜索: '#searchList li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
|
||||
},
|
||||
首图2: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/list/fyclass-fypage.html',
|
||||
searchUrl: '/vodsearch/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {
|
||||
'User-Agent': 'UC_UA',
|
||||
// "Cookie": ""
|
||||
},
|
||||
// class_parse:'.stui-header__menu li:gt(0):lt(7);a&&Text;a&&href;/(\\d+).html',
|
||||
class_parse: '.stui-header__menu li:gt(0):lt(7);a&&Text;a&&href;.*/(.*?).html',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: 'ul.stui-vodlist.clearfix;li;a&&title;.lazyload&&data-original;.pic-text&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: '.stui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
|
||||
二级: {
|
||||
"title": ".stui-content__detail .title&&Text;.stui-content__detail p:eq(-2)&&Text",
|
||||
"img": ".stui-content__thumb .lazyload&&data-original",
|
||||
"desc": ".stui-content__detail p:eq(0)&&Text;.stui-content__detail p:eq(1)&&Text;.stui-content__detail p:eq(2)&&Text",
|
||||
"content": ".detail&&Text",
|
||||
"tabs": ".stui-vodlist__head h3",
|
||||
"lists": ".stui-content__playlist:eq(#id) li"
|
||||
},
|
||||
搜索: 'ul.stui-vodlist__media:eq(0) li,ul.stui-vodlist:eq(0) li,#searchList li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
|
||||
搜索1: 'ul.stui-vodlist&&li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
|
||||
搜索2: 'ul.stui-vodlist__media&&li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
|
||||
},
|
||||
默认: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/vodshow/fyclass--------fypage---.html',
|
||||
searchUrl: '/vodsearch/-------------.html?wd=**',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
},
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
double: true, // 推荐内容是否双层定位
|
||||
},
|
||||
vfed: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/index.php/vod/show/id/fyclass/page/fypage.html',
|
||||
searchUrl: '/index.php/vod/search/page/fypage/wd/**.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {
|
||||
'User-Agent': 'UC_UA',
|
||||
},
|
||||
// class_parse:'.fed-pops-navbar&&ul.fed-part-rows&&a.fed-part-eone:gt(0):lt(5);a&&Text;a&&href;.*/(.*?).html',
|
||||
class_parse: '.fed-pops-navbar&&ul.fed-part-rows&&a;a&&Text;a&&href;.*/(.*?).html',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: 'ul.fed-list-info.fed-part-rows;li;a.fed-list-title&&Text;a&&data-original;.fed-list-remarks&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: '.fed-list-info&&li;a.fed-list-title&&Text;a&&data-original;.fed-list-remarks&&Text;a&&href',
|
||||
二级: {
|
||||
"title": "h1.fed-part-eone&&Text;.fed-deta-content&&.fed-part-rows&&li&&Text",
|
||||
"img": ".fed-list-info&&a&&data-original",
|
||||
"desc": ".fed-deta-content&&.fed-part-rows&&li:eq(1)&&Text;.fed-deta-content&&.fed-part-rows&&li:eq(2)&&Text;.fed-deta-content&&.fed-part-rows&&li:eq(3)&&Text",
|
||||
"content": ".fed-part-esan&&Text",
|
||||
"tabs": ".fed-drop-boxs&&.fed-part-rows&&li",
|
||||
"lists": ".fed-play-item:eq(#id)&&ul:eq(1)&&li"
|
||||
},
|
||||
搜索: '.fed-deta-info;h1&&Text;.lazyload&&data-original;.fed-list-remarks&&Text;a&&href;.fed-deta-content&&Text',
|
||||
},
|
||||
海螺3: {
|
||||
title: '',
|
||||
host: '',
|
||||
searchUrl: '/v_search/**----------fypage---.html',
|
||||
url: '/vod_____show/fyclass--------fypage---.html',
|
||||
headers: {
|
||||
'User-Agent': 'MOBILE_UA'
|
||||
},
|
||||
timeout: 5000,
|
||||
class_parse: 'body&&.hl-nav li:gt(0);a&&Text;a&&href;.*/(.*?).html',
|
||||
cate_exclude: '明星|专题|最新|排行',
|
||||
limit: 40,
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
推荐: '.hl-vod-list;li;a&&title;a&&data-original;.remarks&&Text;a&&href',
|
||||
double: true,
|
||||
一级: '.hl-vod-list&&.hl-list-item;a&&title;a&&data-original;.remarks&&Text;a&&href',
|
||||
二级: {
|
||||
"title": ".hl-infos-title&&Text;.hl-text-conch&&Text",
|
||||
"img": ".hl-lazy&&data-original",
|
||||
"desc": ".hl-infos-content&&.hl-text-conch&&Text",
|
||||
"content": ".hl-content-text&&Text",
|
||||
"tabs": ".hl-tabs&&a",
|
||||
"lists": ".hl-plays-list:eq(#id)&&li"
|
||||
},
|
||||
搜索: '.hl-list-item;a&&title;a&&data-original;.remarks&&Text;a&&href',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
},
|
||||
海螺2: {
|
||||
title: '',
|
||||
host: '',
|
||||
searchUrl: '/index.php/vod/search/page/fypage/wd/**/',
|
||||
url: '/index.php/vod/show/id/fyclass/page/fypage/',
|
||||
headers: {
|
||||
'User-Agent': 'MOBILE_UA'
|
||||
},
|
||||
timeout: 5000,
|
||||
class_parse: '#nav-bar li;a&&Text;a&&href;id/(.*?)/',
|
||||
limit: 40,
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
推荐: '.list-a.size;li;a&&title;.lazy&&data-original;.bt&&Text;a&&href',
|
||||
double: true,
|
||||
一级: '.list-a&&li;a&&title;.lazy&&data-original;.list-remarks&&Text;a&&href',
|
||||
二级: {
|
||||
"title": "h2&&Text;.deployment&&Text",
|
||||
"img": ".lazy&&data-original",
|
||||
"desc": ".deployment&&Text",
|
||||
"content": ".ec-show&&Text",
|
||||
"tabs": "#tag&&a",
|
||||
"lists": ".play_list_box:eq(#id)&&li"
|
||||
},
|
||||
搜索: '.search-list;a&&title;.lazy&&data-original;.deployment&&Text;a&&href',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
},
|
||||
短视: {
|
||||
title: '',
|
||||
host: '',
|
||||
// homeUrl:'/',
|
||||
url: '/channel/fyclass-fypage.html',
|
||||
searchUrl: '/search.html?wd=**',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {//网站的请求头,完整支持所有的,常带ua和cookies
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
// "Cookie": "searchneed=ok"
|
||||
},
|
||||
class_parse: '.menu_bottom ul li;a&&Text;a&&href;.*/(.*?).html',
|
||||
cate_exclude: '解析|动态',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: '.indexShowBox;ul&&li;a&&title;img&&data-src;.s1&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: '.pic-list&&li;a&&title;img&&data-src;.s1&&Text;a&&href',
|
||||
二级: {
|
||||
"title": "h1&&Text;.content-rt&&p:eq(0)&&Text",
|
||||
"img": ".img&&img&&data-src",
|
||||
"desc": ".content-rt&&p:eq(1)&&Text;.content-rt&&p:eq(2)&&Text;.content-rt&&p:eq(3)&&Text;.content-rt&&p:eq(4)&&Text;.content-rt&&p:eq(5)&&Text",
|
||||
"content": ".zkjj_a&&Text",
|
||||
"tabs": ".py-tabs&&option",
|
||||
"lists": ".player:eq(#id) li"
|
||||
},
|
||||
搜索: '.sr_lists&&ul&&li;h3&&Text;img&&data-src;.int&&p:eq(0)&&Text;a&&href',
|
||||
},
|
||||
短视2:{
|
||||
title: '',
|
||||
host: '',
|
||||
class_name:'电影&电视剧&综艺&动漫',
|
||||
class_url:'1&2&3&4',
|
||||
searchUrl: '/index.php/ajax/suggest?mid=1&wd=**',
|
||||
searchable: 2,
|
||||
quickSearch: 0,
|
||||
headers:{'User-Agent':'MOBILE_UA'},
|
||||
url: '/index.php/api/vod#type=fyclass&page=fypage',
|
||||
filterable:0,//是否启用分类筛选,
|
||||
filter_url:'',
|
||||
filter: {},
|
||||
filter_def:{},
|
||||
detailUrl:'/index.php/vod/detail/id/fyid.html',
|
||||
推荐:'.list-vod.flex .public-list-box;a&&title;.lazy&&data-original;.public-list-prb&&Text;a&&href',
|
||||
一级:'js:let body=input.split("#")[1];let t=Math.round(new Date/1e3).toString();let key=md5("DS"+t+"DCC147D11943AF75");let url=input.split("#")[0];body=body+"&time="+t+"&key="+key;print(body);fetch_params.body=body;let html=post(url,fetch_params);let data=JSON.parse(html);VODS=data.list.map(function(it){it.vod_pic=urljoin2(input.split("/i")[0],it.vod_pic);return it});',
|
||||
二级:{
|
||||
"title":".slide-info-title&&Text;.slide-info:eq(3)--strong&&Text",
|
||||
"img":".detail-pic&&data-original",
|
||||
"desc":".fraction&&Text;.slide-info-remarks:eq(1)&&Text;.slide-info-remarks:eq(2)&&Text;.slide-info:eq(2)--strong&&Text;.slide-info:eq(1)--strong&&Text",
|
||||
"content":"#height_limit&&Text",
|
||||
"tabs":".anthology.wow.fadeInUp.animated&&.swiper-wrapper&&a",
|
||||
"tab_text":".swiper-slide&&Text",
|
||||
"lists":".anthology-list-box:eq(#id) li"
|
||||
},
|
||||
搜索:'json:list;name;pic;;id',
|
||||
}
|
||||
};
|
||||
return JSON.parse(JSON.stringify(mubanDict));
|
||||
}
|
||||
var mubanDict = getMubans();
|
||||
var muban = getMubans();
|
||||
export default {muban,getMubans};
|
Loading…
x
Reference in New Issue
Block a user