From c85a68820ae66d407c3afcc29b3fb8251941e3a7 Mon Sep 17 00:00:00 2001
From: src48597962 <48597962@qq.com>
Date: Sun, 23 Jun 2024 14:29:20 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'SrcJyAliDisk.js'?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
SrcJyAliDisk.js | 357 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 355 insertions(+), 2 deletions(-)
diff --git a/SrcJyAliDisk.js b/SrcJyAliDisk.js
index 4a2e01e5..fa40bae0 100644
--- a/SrcJyAliDisk.js
+++ b/SrcJyAliDisk.js
@@ -37,7 +37,7 @@ function aliShareUrl(input) {
}
})
- if (share_id && share_id != "undefined") {
+ if (share_id) {
aliShare(share_id, folder_id, share_pwd);
} else {
back(false);
@@ -1102,7 +1102,7 @@ function myDiskSearch(input) {
}
// 聚影二级切源
-function yunDiskSearch(name) {
+function JYerjiSousuo(name) {
//showLoading('搜源中,请稍后...');
let updateItemid = "云盘_" + name + "_loading";
let diskMark = storage0.getMyVar('diskMark') || {};//二级换源缓存
@@ -1258,4 +1258,357 @@ function yunDiskSearch(name) {
clearMyVar("SrcJu_停止搜索线程");
toast("无接口");
}
+}
+
+function JYerjiAliShare(share_id, folder_id, share_pwd) {
+ let my_params = {};
+ if($.type(MY_PARAMS)!='undefined'){
+ my_params = MY_PARAMS;
+ }
+ addListener("onClose", $.toString((isback) => {
+ if (getMyVar('聚影云盘自动返回') && isback == 1) {
+ back(false);
+ }
+ clearMyVar('云盘共享链接页面标题');
+ }, my_params.back || 0));
+ clearMyVar('聚影云盘自动返回');
+
+ let d = [];
+ let filterFiles = [];
+
+ try {
+ if (!userinfo.refresh_token) {
+ d = d.concat(myDiskMenu(0));
+ } else {
+ share_pwd = share_pwd || "";
+ let get_sharetoken = getShareToken(share_id, share_pwd);
+ let sharetoken = get_sharetoken.share_token;
+ let getbyshare = {};
+
+ d.push({
+ title: "换源",
+ url: $().lazyRule((name, isback) => {
+ if (isback > 0) {
+ putMyVar('聚影云盘自动返回', '1');
+ back(false);
+ return 'hiker://empty';
+ } else if (name) {
+ return $('hiker://empty#noRecordHistory##noHistory#').rule((name) => {
+ let d = [];
+ d.push({
+ title: name + "-云盘聚合搜索",
+ url: "hiker://empty",
+ col_type: "text_center_1",
+ extra: {
+ id: "listloading",
+ lineVisible: false
+ }
+ })
+ setResult(d);
+ require(config.依赖.match(/http(s)?:\/\/.*\//)[0].replace('/Ju/', '/master/') + 'SrcJyAliDisk.js');
+ aliDiskSearch(name);
+ }, name)
+ } else {
+ return 'hiker://empty';
+ }
+ }, my_params.name || "", my_params.back || 0),
+ col_type: 'icon_5',
+ img: 'https://hikerfans.com/tubiao/grey/175.png',
+ extra: {
+ longClick: [{
+ title: "上级目录",
+ js: $.toString((id) => {
+ if (!id) {
+ return "toast://已经是根目录了";
+ } else {
+ let ids = id.split;
+ return $("").rule((ids) => {
+ require(config.依赖.match(/http(s)?:\/\/.*\//)[0].replace('/Ju/', '/master/') + 'SrcJyAliDisk.js');
+ aliShare(ids[0], ids[1], ids[2]);
+ }, ids);
+ }
+ }, my_params.dirid || "")
+ }]
+ }
+ },
+ {
+ title: "样式",
+ url: $(['text_1', 'movie_2', 'card_pic_3', 'avatar']).select(() => {
+ setItem('aliyun_style', input);
+ refreshPage();
+ return 'toast://已切换';
+ }),
+ col_type: 'icon_5',
+ img: 'https://hikerfans.com/tubiao/grey/168.png'
+ },
+ {
+ title: "排序",
+ url: $(ordersKeys, 2).select(() => {
+ setItem('aliyun_order', input);
+ refreshPage();
+ return 'toast://切换成功';
+ }),
+ col_type: 'icon_5',
+ img: 'https://hikerfans.com/tubiao/grey/76.png'
+ },
+ {
+ title: getItem('aliyun_playMode', '智能')=="原画"?"原画"+getItem('aliyun_openInt', '1'):getItem('aliyun_playMode', '智能'),
+ url: $(['智能', '转码', '原画', '原画接口']).select(() => {
+ if(input=='原画接口'){
+ return $(['接口1(alist)', '接口2(webdav)']).select(() => {
+ clearMyVar('aliopentoken');
+ if(input=='接口1(alist)'){
+ clearItem('aliyun_openInt');
+ }else{
+ require(config.依赖.match(/http(s)?:\/\/.*\//)[0].replace('/Ju/', '/master/') + 'SrcJyAliPublic.js');
+ if(aliOpenTokenObj.refresh_token_2){
+ setItem('aliyun_openInt', '2');
+ }else{
+ let loyopentoken2;
+ try{
+ let loyopen = eval('('+fetch("hiker://files/rules/LoyDgIk/aliOpenToken.json")+')') || {};
+ loyopentoken2 = loyopen.isV2?loyopen.RefreshTokenOpen:"";
+ aliOpenTokenObj.refresh_token_2 = loyopentoken2;
+ aliconfig.opentoken = aliOpenTokenObj;
+ writeFile(alicfgfile, JSON.stringify(aliconfig));
+ }catch(e){
+ log(e.message);
+ }
+ if(loyopentoken2){
+ setItem('aliyun_openInt', '2');
+ }else{
+ return $('','输入阿里webdav口令,留空打开网页获取').input((alicfgfile,aliconfig) => {
+ if(input==''){
+ return 'web://https://messense-aliyundrive-webdav-backendrefresh-token-ucs0wn.streamlit.app';
+ }else{
+ let aliOpenTokenObj = aliconfig.opentoken || {};
+ aliOpenTokenObj.refresh_token_2 = input;
+ aliconfig.opentoken = aliOpenTokenObj;
+ writeFile(alicfgfile, JSON.stringify(aliconfig));
+ setItem('aliyun_openInt', '2');
+ }
+ },alicfgfile,aliconfig)
+
+ }
+ }
+ }
+ refreshPage();
+ return 'toast://已切换为'+input;
+ })
+ }else{
+ setItem('aliyun_playMode', input);
+ refreshPage();
+ return 'toast://已切换为'+input;
+ }
+ }),
+ col_type: 'icon_5',
+ img: 'https://hikerfans.com/tubiao/grey/100.png'
+ },
+ {
+ title: '转存',
+ url: `smartdrive://share/browse?shareId=${share_id}&sharePwd=${share_pwd}`,
+ col_type: 'icon_5',
+ img: 'https://hikerfans.com/tubiao/grey/206.png',
+ extra: {
+ longClick: [{
+ title: "💾转存",
+ js: $.toString((obj) => {
+ storage0.putMyVar('copydate', obj);
+ return $("hiker://empty").rule(() => {
+ addListener("onClose", $.toString(() => {
+ clearMyVar('copydate');
+ }));
+
+ require(config.依赖.match(/http(s)?:\/\/.*\//)[0].replace('/Ju/', '/master/') + 'SrcJyAliDisk.js');
+ aliMyDisk('', 0, '');
+ })
+ },{sharetoken:sharetoken,share_id:share_id,authorization:authorization,file_id:folder_id})
+ }]
+ }
+ },
+ {
+ col_type: 'line_blank'
+ })
+
+ if (errorCode[get_sharetoken.code]) {
+ d.push({
+ title: errorCode[get_sharetoken.code],
+ url: 'hiker://empty',
+ col_type: "text_center_1"
+ })
+ setResult(d);
+ } else {
+ let postdata = { "share_id": share_id, "parent_file_id": folder_id || "root", "limit": 200, "image_thumbnail_process": "image/resize,w_256/format,jpeg", "image_url_process": "image/resize,w_1920/format,jpeg/interlace,1", "video_thumbnail_process": "video/snapshot,t_1000,f_jpg,ar_auto,w_256", "order_by": orderskey.split('#')[0], "order_direction": orderskey.split('#')[1] };
+ headers['x-share-token'] = sharetoken;
+ getbyshare = JSON.parse(request('https://api.aliyundrive.com/adrive/v2/file/list_by_share', { headers: headers, body: postdata, method: 'POST' }));
+
+ if (errorCode[getbyshare.code]) {
+ d.push({
+ title: errorCode[getbyshare.code],
+ url: 'hiker://empty',
+ col_type: "text_center_1"
+ })
+ setResult(d);
+ }
+ }
+ let sharelist = getbyshare.items || [];
+ sharelist = sharelist.filter(item => {
+ return item.type == "file" || (item.type == "folder" && !folderFilter.test(item.name));
+ })
+ if (sharelist.length == 1 && sharelist[0].type == "folder") {
+ putMyVar('云盘共享链接页面标题', sharelist[0].name);
+ java.lang.Thread.sleep(1000);
+ aliShare(share_id, sharelist[0].file_id, share_pwd);
+ } else if (sharelist.length > 0) {
+ let sublist = sharelist.filter(item => {
+ return item.type == "file" && /srt|vtt|ass/.test(item.file_extension);
+ })
+ let dirlist = sharelist.filter((item) => {
+ return item.type == "folder";
+ })
+ dirlist.forEach((item) => {
+ d.push({
+ title: item.name,
+ img: "hiker://files/cache/src/文件夹.svg",//#noRecordHistory##noHistory#
+ url: $("hiker://empty##https://www.aliyundrive.com/s/" + item.share_id + (item.file_id ? "/folder/" + item.file_id : "")).rule((share_id, folder_id, share_pwd) => {
+ require(config.依赖.match(/http(s)?:\/\/.*\//)[0].replace('/Ju/', '/master/') + 'SrcJyAliDisk.js');
+ aliShare(share_id, folder_id, share_pwd);
+ }, item.share_id, item.file_id, share_pwd),
+ col_type: style,
+ extra: {
+ pageTitle: item.name,
+ name: my_params.name || "",
+ back: 1,
+ dirid: share_id + '_' + folder_id + '_' + share_pwd,
+ longClick: [{
+ title: "💾转存",
+ js: $.toString((obj) => {
+ storage0.putMyVar('copydate', obj);
+ return $("hiker://empty").rule(() => {
+ addListener("onClose", $.toString(() => {
+ clearMyVar('copydate');
+ }));
+
+ require(config.依赖.match(/http(s)?:\/\/.*\//)[0].replace('/Ju/', '/master/') + 'SrcJyAliDisk.js');
+ aliMyDisk('', 0, '');
+ })
+ },{sharetoken:sharetoken,share_id:share_id,authorization:authorization,file_id:item.file_id})
+ }]
+ }
+ })
+ })
+ let filelist = sharelist.filter((item) => {
+ return item.type == "file";
+ })
+ if (getItem('aliyun_order', '聚影排序') == "聚影排序") {
+ filelist.sort(SortList);
+ }
+
+ filelist.forEach((item) => {
+ let filesize = item.size / 1024 / 1024;
+ let it = {
+ title: item.name,
+ img: item.thumbnail || (item.category == "video" ? "hiker://files/cache/src/影片.svg" : item.category == "audio" ? "hiker://files/cache/src/音乐.svg" : item.category == "image" ? "hiker://files/cache/src/图片.png" : "https://img.alicdn.com/imgextra/i1/O1CN01mhaPJ21R0UC8s9oik_!!6000000002049-2-tps-80-80.png"),
+ desc: filesize < 1024 ? filesize.toFixed(2) + 'MB' : (filesize / 1024).toFixed(2) + 'GB',
+ col_type: style,
+ extra: {
+ id: item.file_id,
+ longClick: [{
+ title: "💾转存",
+ js: $.toString((obj) => {
+ storage0.putMyVar('copydate', obj);
+ return $("hiker://empty").rule(() => {
+ addListener("onClose", $.toString(() => {
+ clearMyVar('copydate');
+ }));
+
+ require(config.依赖.match(/http(s)?:\/\/.*\//)[0].replace('/Ju/', '/master/') + 'SrcJyAliDisk.js');
+ aliMyDisk('', 0, '');
+ })
+ },{sharetoken:sharetoken,share_id:share_id,authorization:authorization,file_id:item.file_id})
+ }]
+ }
+ }
+ if (item.category == "video") {
+ let sub_file_id;
+ if (sublist.length == 1) {
+ sub_file_id = sublist[0].file_id;
+ } else if (sublist.length > 1) {
+ sublist.forEach(it => {
+ let subnmae = it.name.substring(0, it.name.lastIndexOf(".")).replace(/\.chs|\.eng/g, '');
+ if (item.name.includes(subnmae)) {
+ sub_file_id = it.file_id;
+ }
+ })
+ if (!sub_file_id) {
+ sub_file_id = sublist[0].file_id;
+ }
+ }
+ it.url = $("").lazyRule((share_id, file_id, sub_file_id, share_pwd) => {
+ require(config.依赖.match(/http(s)?:\/\/.*\//)[0].replace('/Ju/', '/master/') + 'SrcJyAliPublic.js');
+ let play = getAliUrl(share_id, file_id, share_pwd);
+ if (play.urls && play.urls.length > 0) {
+ let subtitle;
+ if (sub_file_id) {
+ subtitle = getSubtitle(share_id, sub_file_id, share_pwd);
+ if (subtitle) {
+ play['subtitle'] = subtitle;
+ }
+ }
+ return JSON.stringify(play);
+ } else {
+ return "toast://获取播放列表失败,看日志有无异常或token无效";
+ }
+ }, item.share_id, item.file_id, sub_file_id || "", share_pwd);
+ d.push(it);
+ } else {
+ it.url = $("").lazyRule((category, file_id, sharedata) => {
+ require(config.依赖.match(/http(s)?:\/\/.*\//)[0].replace('/Ju/', '/master/') + 'SrcJyAliPublic.js');
+ let file_url = aliOpenPlayUrl(file_id, sharedata);
+ if (category == "audio") {
+ return file_url + ";{Referer@https://www.aliyundrive.com/}#isMusic=true#";
+ } else if (category == "image") {
+ return file_url + "#.jpg@Referer=https://www.aliyundrive.com/";
+ } else {
+ return "download://" + file_url + ";{Referer@https://www.aliyundrive.com/}";
+ }
+ }, item.category, item.file_id, { sharetoken: sharetoken, share_id: item.share_id });
+ filterFiles.push(it);
+ }
+ })
+ d.push({
+ title: "““””已开启文件过滤,仅显示视频文件",
+ url: filterFiles.length == 0 ? "hiker://empty" : $("").lazyRule((filterFiles, folder_id) => {
+ addItemAfter("sharelist_" + folder_id, filterFiles);
+ updateItem("sharelist_" + folder_id, {
+ url: "hiker://empty",
+ title: "““””已显示全部文件"
+ });
+ return "toast://已加载全部文件";
+ }, filterFiles, folder_id),
+ col_type: "text_center_1",
+ extra: {
+ id: "sharelist_" + folder_id
+ }
+ })
+ } else {
+ toast('列表为空');
+ }
+ }
+ } catch (e) {
+ log('获取共享文件列表失败>' + e.message);
+ d.push({
+ title: '该分享已失效或异常',
+ url: 'hiker://empty',
+ col_type: "text_center_1"
+ })
+ toast('该分享已失效或异常,可刷新确认下');
+ }
+ setResult(d);
+ if(typeof (MY_PARAMS) == "undefined" || !MY_PARAMS.pageTitle){
+ setPageTitle(getMyVar('云盘共享链接页面标题', '云盘共享文件') + ' | 聚影√');
+ }
+ setLastChapterRule('js:' + $.toString(() => {
+ setResult('');
+ }))
}
\ No newline at end of file