forked from moeloli/baidupan-rapidupload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultisave.html
211 lines (203 loc) · 7.88 KB
/
multisave.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"
/>
<title>百度网盘秒传链接批量转存</title>
<link
rel="stylesheet"
href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css"
/>
<script src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script>
<script
src="https://cdn.staticfile.org/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"
></script>
<script
src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"
></script>
<script type="text/javascript" src="./dist/browser/json-url.js"></script>
<script type="text/javascript">
function atou(str) {
return decodeURIComponent(escape(window.atob(str)));
}
function Trim(str){
return str.replace(/(^\s*)|(\s*$)/g, "");
}
function addbdstoken(){
var x=document.getElementById("save")
x.action="https://pan.baidu.com/api/rapidupload?app_id=250528&bdstoken="+ document.getElementById("bdstoken").value +"&channel=chunlei&clienttype=0&rtype=1&web=1"
}
function copy(){
const input = document.querySelector('#copy_script');
input.select();
if (document.execCommand('copy')) {
document.execCommand('copy');
alert('复制成功');
}
}
function getLinkMulti(){
if(document.getElementById('bdstoken').value == ""){
alert('未输入bdstoken');
return;
}
var links = document.getElementById('link').value.split('\n');
for(i=0;i<links.length;i++){
getLink(links[i]);
}
}
function getLink(link) {
if(document.getElementById('bdstoken').value == ""){
alert('未输入bdstoken');
return;
}
var bdpan = link.match(/bdpan:\/\/(.+)/);;
var pcs = link.match('BaiduPCS-Go');
var mengji = link.match(/.{32}#.{32}/);
var bdlink = link.match('bdlink(.+)');
var pan = link.match(/^pan:\/\//);
if (bdpan){
var de_b64 = atou(bdpan[1]);
var md5 = de_b64.match(/\|(.{32})\|/)[1];
var slicemd5 = de_b64.match(/\|([^\|]{32})$/)[1];
var file_length = de_b64.match(/\|([0-9]+)\|/)[1];
var file_name = de_b64.match(/^(.+\.[a-zA-Z]{1,9})\|/)[1];
saveFile(md5, slicemd5, file_length, file_name, bdpan);
}
else if (pcs){
var input = link;
var length = input.match(/length\=([0-9]+)/)[1];
var md5 = input.match(/\-md5\=(.{32})/)[1];
var slicemd5 = input.match(/\-slicemd5\=(.{32})/)[1];
var file_name = input.match(/\"(.+)\"/)[1];
saveFile(md5, slicemd5, length, file_name, pcs);
}
else if (mengji){
var input = link;
var md5 = input.match(/^(.{32})#/)[1];
var slicemd5 = input.match(/#(.{32})#/)[1];
var file_length = input.match(/#([0-9]+)#/)[1];
var file_name = input.match(/#[0-9]+#(.+)$/)[1];
file_name = Trim(file_name);
saveFile(md5, slicemd5, file_length, file_name, mengji);
}
else if (bdlink){
var bdlink1 = link.match('bdlink\=([a-zA-Z0-9\=\/\+]+\={0,2})[\#\?\&]?');
var bdlink2 = link.match('bdlink\=([a-zA-Z0-9\=\/\+]+\={0,2})$');
var de_b64;
if(bdlink1){
de_b64 = atou(bdlink1[1]);
if(de_b64.split('\n').length > 1)
for (i=0;i<de_b64.split('\n').length;i++)
getLink(de_b64.split('\n')[i])
else if(de_b64.split('\n').length == 1)
getLink(de_b64);
}
else if(bdlink2){
var de_b64 = atou(bdlink2[1]);
if(de_b64.split('\n').length > 1)
for (i=0;i<de_b64.split('\n').length;i++){
getLink(de_b64.split('\n')[i])
}
else if(de_b64.split('\n').length == 1)
getLink(de_b64);
}
}
else if (pan){
const lib = JsonUrl('lzw');
lib.decompress(link.match(/^pan:\/\/(.+)/)[1]).then(output => {
for(i=0;i< output.length;i++){saveFile(output[i]['content-md5'],output[i]['slice-md5'],output[i]['content-length'],output[i]['path'],'pan');}})
}
else{
alert('未检测到有效秒传链接');
return;
}
}
function saveFile(md5,slicemd5,length,name,method){
var saveForm = document.createElement("form");
document.body.appendChild(saveForm);
saveForm.method = 'POST';
saveForm.target = '_blank';
saveForm.action = "https://pan.baidu.com/api/rapidupload?app_id=250528&bdstoken="+ document.getElementById("bdstoken").value +"&channel=chunlei&clienttype=0&rtype=1&web=1";
var path = document.createElement("input");
path.setAttribute("type", "hidden");
path.setAttribute("name", "path");
saveForm.appendChild(path);
if (method == 'pcs'){
path.setAttribute("value", name)
}
else
{
path.setAttribute("value",'/' + name)
}
var md5_input = document.createElement("input");
md5_input.setAttribute("type", "hidden");
md5_input.setAttribute("name", "content-md5");
saveForm.appendChild(md5_input);
md5_input.setAttribute("value", md5);
var slice_md5 = document.createElement("input");
slice_md5.setAttribute("type", "hidden");
slice_md5.setAttribute("name", "slice-md5");
saveForm.appendChild(slice_md5);
slice_md5.setAttribute("value", slicemd5);
var file_length = document.createElement("input");
file_length.setAttribute("type", "hidden");
file_length.setAttribute("name", "content-length");
saveForm.appendChild(file_length);
file_length.setAttribute("value", length);
saveForm.submit();
}
</script>
</head>
<body>
<div id="app">
<div id="container" class="container">
<div class="row">
<div class="col-sm-8 offset-sm-2 col-md-6 offset-md-3 text-center">
<h1>百度网盘秒传链接批量转存</h1>
<p>v0.2</p>
<p>
<b>请先阅读使用教程</b></br><a href='./manual.html' target=_blank><b>本站使用教程</b></a></br></p>
<p><a href='./index.html'>秒传链接在线转存</a></br>
<a href='./gen.html'>秒传链接在线生成</a></br>
<a href='./convert.html'>秒传链接在线转换</a></p>
<p><b>批量转存必读</b>
</br>
<b>请允许本站弹出多个窗口以实现批量请求</b></br>
<img src="https://s1.ax1x.com/2020/05/10/Y1OqX9.png" height="212">
</p>
</br>
复制代码,粘贴到<a href="https://pan.baidu.com/disk/home" target=_blank>百度网盘</a>地址栏,运行获取bdstoken</br>
如果代码开头的 <b>javascript:</b> 消失,请手动添加 <b>javascript:</b></br>
</div>
<div class="col-sm-8 offset-sm-2 col-md-6 offset-md-3 text-center">
<p><input class="form-control" id="copy_script" value="javascript:for(i=0;i < document.getElementsByTagName('script').length;i++){var scripts=document.getElementsByTagName('script')[i].innerHTML.match(/\"bdstoken\"\:\"(\w{32})\"/);if(scripts!=null){var bdstoken=scripts[0].match(/\"bdstoken\"\:\"(\w{32})\"/)[1];}}const input=document.createElement('input');document.body.appendChild(input);input.setAttribute('value',bdstoken);input.select();if(document.execCommand('copy')){document.execCommand('copy');alert('bdstoken '+bdstoken+'\n复制成功');}document.body.removeChild(input);">
</p>
<button class="btn btn-primary" id="copy" onclick=copy();>复制代码</button>
</div>
<div id="body" class="col-sm-8 offset-sm-2 col-md-6 offset-md-3 text-center">
<div>
</br><label for="bdstoken">bdstoken(必填)</label>
<p><input name="bdstoken" class="form-control" id="bdstoken" placeholder="32位"></p>
</div>
<div>
<label for="link">秒传链接</label>
<p><textarea name="link" id="link" class="form-control" placeholder="bdpan... / BaiduPCS-Go ... / 5b1...#b3a... " rows=6></textarea></p>
</div>
<p><button onclick=getLinkMulti(); class="btn btn-primary">解析链接并转存</button></p>
</div>
<div id="footer" class="col-sm-8 offset-sm-2 col-md-6 offset-md-3 text-center">
<p>显示 {"errno":2} 为保存失败,检查输入的内容是否正确</br>{"errno":404} 为服务器无对应文件</br>{"errno":-6} 为未登录</br>{"errno":0} 为保存成功
</br>
<b>所有请求在用户端进行,本站不保存任何链接</b>
</p>
</div>
</div>
</div></div></div>
</body>