forked from reruin/sharelist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
174 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ data: | |
- user1:111111 | ||
- user2:aaaaaa | ||
``` | ||
```basic```是内置的验证方式,使用用户名密码对进行判断,上面的例子中可使用```user1```的密码为```111```,```user2```的密码为```aaaaaa```。[请参考](blob/master/example/SecretFolder/.passwd)。 | ||
```basic```是内置的验证方式,使用用户名密码对进行判断,上面的例子中可使用```user1```的密码为```111```,```user2```的密码为```aaaaaa```。请参考[example/SecretFolder/.passwd](example)。 | ||
|
||
### 虚拟目录 | ||
在需创建虚拟目录处新建```目录名.d.ln```文件。 其内容为```挂载源:挂载路径``` | ||
|
@@ -86,7 +86,12 @@ ShareListDrive是ShareList内置的一种虚拟文件系统,使用yaml构建 | |
#### OneDrive For Business | ||
提供对OneDrive Business的访问。挂载标示odb,分享的url作为路径。 | ||
#### OpenLoad | ||
提供对[OpenLoad](https://openload.co/)的访问。挂载标示openload,```ApiLogin:ApiKey@folderId```作为路径,省略@则从根目录开始列出文件。。 | ||
提供对[OpenLoad](https://openload.co/)的访问支持。挂载标示openload,```ApiLogin:ApiKey@folderId```作为路径,省略@则从根目录开始列出文件。 | ||
#### Lanzou蓝奏云 | ||
提供对[蓝奏云](https://www.lanzou.com/)的访问支持。挂载标示lanzou,```passwd@folderId```作为路径,无密码则直接使用```folderId```作为路径。 | ||
插件为目录 以及 mp4/jpg等禁止上传的格式提供解析支持。 | ||
对于文件,将```xxx.mp4```命名为```xxx.mp4.ct```后再上传,插件将自动解析为mp4文件。 | ||
对于目录,创建```目录名[email protected]```的文件上传即可。 | ||
### 插件开发 | ||
待完善 | ||
|
@@ -119,4 +124,3 @@ WebDAV 目录 `http://localhost:33001/webdav` | |
[](https://heroku.com/deploy?template=https://github.com/reruin/sharelist-heroku) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lanzou:b480558 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
/* | ||
* www.lanzous.com | ||
* lanzou:password@foldId / foldId | ||
*/ | ||
|
||
const name = 'Lanzous' | ||
|
||
const version = '1.0' | ||
|
||
const protocols = ['lanzou'] | ||
|
||
const defaultProtocol = 'lanzou' | ||
|
||
const host = 'https://www.lanzous.com' | ||
|
||
module.exports = ({ request , getConfig , datetime , cache }) => { | ||
|
||
const parse = (id) => { | ||
let tmp = id.split('@') | ||
let passwd , fid | ||
if( tmp.length == 2 ){ | ||
passwd = tmp[0] | ||
fid = tmp[1] | ||
}else if( tmp.length == 1){ | ||
fid = id | ||
} | ||
return { passwd , fid } | ||
} | ||
|
||
const getFormDataForFolder = (body) => { | ||
let data = (body.match(/(?<=data\s*:\s*)\{.*?\}/) || [''])[0] | ||
if( data ){ | ||
let formdata = {} | ||
|
||
try{ | ||
let field_k = data.match(/(?<=\'k\':)[^\s,\}]+/)[0] | ||
let field_t = data.match(/(?<=\'t\':)[^\s,\}]+/)[0] | ||
let value_k = body.match(new RegExp('(?<='+field_k+"\\s*=\\s*')[^']+"))[0] | ||
let value_t = body.match(new RegExp('(?<='+field_t+"\\s*=\\s*')[^']+"))[0] // timestamp | ||
data = data.replace(new RegExp('(pgs|'+field_k+'|'+field_t+')','g'),'""').replace(/\'/g,'"').replace(/(?<=:)pwd/,'""') | ||
|
||
formdata = JSON.parse( data ) | ||
formdata.k = value_k | ||
formdata.t = value_t | ||
delete formdata.pwd | ||
return formdata | ||
}catch(e){ | ||
return false | ||
} | ||
|
||
}else{ | ||
return false | ||
} | ||
} | ||
|
||
const updateFile = (f) => { | ||
|
||
if(f.name.endsWith('.d.txt')){ | ||
f.id = f.name.split('.').slice(-3,-2)[0] | ||
f.name = f.name.split('.').slice(0,-3).join('.') | ||
f.type = 'folder' | ||
f.size = null | ||
f.ext = null | ||
} | ||
|
||
return f | ||
} | ||
|
||
// gd folder => files | ||
const folder = async(id) => { | ||
let resid = `${defaultProtocol}:${id}` | ||
let resp = false | ||
let r = cache(resid) | ||
if(r) { | ||
resp = r | ||
if( | ||
resp.$cached_at && | ||
resp.children && | ||
( Date.now() - resp.$cached_at < getConfig().max_age_dir) | ||
|
||
){ | ||
console.log('get folder from cache') | ||
return resp | ||
} | ||
} | ||
|
||
let params = parse(id) | ||
|
||
if(params.fid){ | ||
let { body , headers } = await request.get(host+'/'+params.fid) | ||
let cookie = headers['set-cookie'].join('; ') | ||
|
||
let formdata = getFormDataForFolder(body) | ||
if( formdata ){ | ||
formdata.pg = 1 | ||
if(params.passwd) { | ||
formdata.pwd = params.passwd | ||
} | ||
|
||
let res = await request.post(`${host}/filemoreajax.php` , formdata ,{headers:{'Cookie':cookie} , json:true}) | ||
|
||
if( res.body && res.body.text){ | ||
resp = {id , type:'folder' , protocol:defaultProtocol} | ||
let children = [] | ||
|
||
res.body.text.forEach( i => { | ||
let name = i.name_all.replace(/\.ct$/,'') | ||
let child = { | ||
id:i.id, | ||
name:name, | ||
ext:name.split('.').pop(), | ||
protocol:defaultProtocol, | ||
// updated_at:datetime(i.upload_at*1000), | ||
displaySize:i.size, | ||
type : undefined, | ||
} | ||
|
||
children.push(updateFile({ | ||
id:i.id, | ||
name:name, | ||
ext:name.split('.').pop(), | ||
protocol:defaultProtocol, | ||
// updated_at:datetime(i.upload_at*1000), | ||
displaySize:i.size, | ||
type : undefined, | ||
})) | ||
}) | ||
|
||
//folder 额外保存 | ||
resp.children = children | ||
resp.$cached_at = Date.now() | ||
|
||
cache(resid,resp) | ||
} | ||
} | ||
|
||
} | ||
|
||
return resp | ||
} | ||
|
||
/** | ||
* 获取文件实际路径 | ||
*/ | ||
const file = async(id , data = {}) =>{ | ||
|
||
let { body } = await request.get(`${host}/tp/${id}` , {headers:{'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; 1503-M02 Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.2 TBS/036558 Safari/537.36 MicroMessenger/6.3.25.861 NetType/WIFI Language/zh_CN'}}) | ||
let url = body.match(/(?<=submit\.href\s*=\s*urlpt\s*\+\s*')[^']+/)[0] | ||
let base = body.match(/(?<=urlpt\s*=\s*')[^']+/)[0] | ||
url = base + url | ||
data.url = url | ||
data.$cached_at = Date.now() | ||
cache.save() | ||
return data | ||
} | ||
|
||
return { name , version, drive:{ protocols, folder , file } } | ||
} |