mirror of
https://github.com/Bao-qing/123pan.git
synced 2025-11-13 12:16:07 +08:00
为android协议添加文件夹打包下载
This commit is contained in:
parent
7d8b00a343
commit
8766e3564f
65
README.md
65
README.md
|
|
@ -21,9 +21,9 @@
|
||||||
1. 确保已安装 Python 3.x。
|
1. 确保已安装 Python 3.x。
|
||||||
|
|
||||||
2. 安装所需的 Python 库:
|
2. 安装所需的 Python 库:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install requests
|
pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
### 配置文件
|
### 配置文件
|
||||||
|
|
@ -32,26 +32,33 @@
|
||||||
|
|
||||||
### 运行脚本
|
### 运行脚本
|
||||||
|
|
||||||
可以直接下载release的可执行文件运行或运行python脚本。
|
```
|
||||||
|
可以直接下载release的可执行文件运行或运行python脚本。
|
||||||
|
```
|
||||||
|
|
||||||
脚本运行:
|
```
|
||||||
|
脚本运行:
|
||||||
|
```
|
||||||
|
|
||||||
1. 克隆或下载本项目代码到本地。
|
1. 克隆或下载本项目代码到本地。
|
||||||
|
|
||||||
2. 打开终端或命令提示符,进入项目目录。
|
2. 打开终端或命令提示符,进入项目目录。
|
||||||
|
|
||||||
3. 运行脚本:
|
3. 运行脚本:
|
||||||
|
|
||||||
使用安卓客户端协议
|
使用安卓客户端协议
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python android.py
|
python android.py
|
||||||
```
|
```
|
||||||
|
|
||||||
使用web协议
|
```
|
||||||
|
使用web协议
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python 123pan.py
|
python web.py
|
||||||
```
|
```
|
||||||
|
|
||||||
### 命令
|
### 命令
|
||||||
|
|
||||||
|
|
@ -59,36 +66,39 @@
|
||||||
- **列出文件**:`ls`
|
- **列出文件**:`ls`
|
||||||
- **刷新目录**:`re`
|
- **刷新目录**:`re`
|
||||||
- **下载文件**:`download <文件编号>`
|
- **下载文件**:`download <文件编号>`
|
||||||
|
|
||||||
|
Android下可以直接下载文件夹
|
||||||
- **获取下载链接** `link <文件编号>`
|
- **获取下载链接** `link <文件编号>`
|
||||||
- **分享文件**:`share`
|
- **分享文件**:`share`
|
||||||
- **删除文件**:`delete <文件编号>`
|
- **删除文件**:`delete <文件编号>`
|
||||||
- **创建文件夹**:`mkdir <文件夹名称>`
|
- **创建文件夹**:`mkdir <文件夹名称>`
|
||||||
- **切换目录**:`cd <目录编号>` 或 `cd ..` 返回上一级目录
|
- **切换目录**:`cd <目录编号>` 或 `cd ..` 返回上一级目录
|
||||||
- **上传文件**:`upload`,然后输入文件路径
|
- **上传文件**:`upload`,然后输入文件路径
|
||||||
|
- **直接输入数字**:进入文件夹,或是下载文件
|
||||||
- **退出**:`exit`
|
- **退出**:`exit`
|
||||||
|
|
||||||
### 示例
|
### 示例
|
||||||
|
|
||||||
1. 登录:
|
1. 登录:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
> log
|
> log
|
||||||
```
|
```
|
||||||
|
|
||||||
2. 列出文件:
|
2. 列出文件:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
> ls↵
|
> ls↵
|
||||||
```
|
```
|
||||||
|
|
||||||
3. 下载文件:
|
3. 下载文件:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
> download 1↵
|
> download 1↵
|
||||||
```
|
```
|
||||||
|
|
||||||
或直接输入文件编号:
|
或直接输入文件编号:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
>54↵
|
>54↵
|
||||||
1.20.0.01_v8a.apk 193.53M
|
1.20.0.01_v8a.apk 193.53M
|
||||||
|
|
@ -97,20 +107,32 @@
|
||||||
[██████████████████████████████████████████████████] 100%
|
[██████████████████████████████████████████████████] 100%
|
||||||
ok
|
ok
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
下载文件夹(android):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
>download 2
|
||||||
|
test
|
||||||
|
将打包下载文件夹,输入1开始下载:1
|
||||||
|
打包下载
|
||||||
|
文件 test.zip 已存在,是否要覆盖?
|
||||||
|
输入1覆盖,2取消:1
|
||||||
|
test.zip 1.78K
|
||||||
|
[██████████████████████████████████████████████████] 100%
|
||||||
|
ok
|
||||||
|
```
|
||||||
|
|
||||||
4. 获取下载链接
|
4. 获取下载链接
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
>link 32
|
>link 32
|
||||||
https://1-180-24-9.pd1.cjjd19.com:30443/(A Long Link)
|
https://1-180-24-9.pd1.cjjd19.com:30443/(A Long Link)
|
||||||
```
|
```
|
||||||
|
|
||||||
获取下载链接后可以使用IDM下载
|
获取下载链接后可以使用IDM下载
|
||||||
|
|
||||||
5. 分享文件:
|
5. 分享文件:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
>share↵
|
>share↵
|
||||||
分享文件的编号:58↵
|
分享文件的编号:58↵
|
||||||
|
|
@ -123,19 +145,19 @@
|
||||||
```
|
```
|
||||||
|
|
||||||
6. 删除文件:
|
6. 删除文件:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
> delete 1
|
> delete 1
|
||||||
```
|
```
|
||||||
|
|
||||||
7. 创建文件夹:
|
7. 创建文件夹:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
> mkdir 新建文件夹
|
> mkdir 新建文件夹
|
||||||
```
|
```
|
||||||
|
|
||||||
8. 上传文件:
|
8. 上传文件:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
>upload
|
>upload
|
||||||
请输入文件路径:C:\(some path)\config
|
请输入文件路径:C:\(some path)\config
|
||||||
|
|
@ -152,4 +174,3 @@
|
||||||
- 请确保在使用过程中网络连接正常。
|
- 请确保在使用过程中网络连接正常。
|
||||||
- 由于使用了模拟安卓客户端协议,可能会有一定的风险,请谨慎使用。
|
- 由于使用了模拟安卓客户端协议,可能会有一定的风险,请谨慎使用。
|
||||||
- 本工具仅供学习和研究使用,请勿用于非法用途。
|
- 本工具仅供学习和研究使用,请勿用于非法用途。
|
||||||
|
|
||||||
|
|
|
||||||
27
android.py
27
android.py
|
|
@ -212,7 +212,7 @@ class Pan123:
|
||||||
down_request_url,
|
down_request_url,
|
||||||
headers=self.header_logined,
|
headers=self.header_logined,
|
||||||
# params={sign[0]: sign[1]},
|
# params={sign[0]: sign[1]},
|
||||||
data=down_request_data,
|
data=json.dumps(down_request_data),
|
||||||
timeout=10
|
timeout=10
|
||||||
)
|
)
|
||||||
# print(linkRes.text)
|
# print(linkRes.text)
|
||||||
|
|
@ -230,15 +230,24 @@ class Pan123:
|
||||||
|
|
||||||
return redirect_url
|
return redirect_url
|
||||||
|
|
||||||
def download(self, file_number):
|
def download(self, file_number,download_path="download/"):
|
||||||
file_detail = self.list[file_number]
|
file_detail = self.list[file_number]
|
||||||
|
if file_detail["Type"] == 1:
|
||||||
|
print("打包下载")
|
||||||
|
file_name = file_detail["FileName"] + ".zip"
|
||||||
|
else:
|
||||||
|
file_name = file_detail["FileName"] # 文件名
|
||||||
down_load_url = self.link(file_number, showlink=False)
|
down_load_url = self.link(file_number, showlink=False)
|
||||||
file_name = file_detail["FileName"] # 文件名
|
|
||||||
if os.path.exists(file_name):
|
if os.path.exists(download_path+file_name):
|
||||||
print("文件 " + file_name + " 已存在,是否要覆盖?")
|
print("文件 " + file_name + " 已存在,是否要覆盖?")
|
||||||
sure_download = input("输入1覆盖,2取消:")
|
sure_download = input("输入1覆盖,2取消:")
|
||||||
if sure_download != "1":
|
if sure_download != "1":
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not os.path.exists(download_path):
|
||||||
|
print("文件夹不存在,创建文件夹")
|
||||||
|
os.makedirs(download_path)
|
||||||
down = requests.get(down_load_url, stream=True, timeout=10)
|
down = requests.get(down_load_url, stream=True, timeout=10)
|
||||||
|
|
||||||
file_size = int(down.headers["Content-Length"]) # 文件大小
|
file_size = int(down.headers["Content-Length"]) # 文件大小
|
||||||
|
|
@ -252,7 +261,7 @@ class Pan123:
|
||||||
time1 = time.time()
|
time1 = time.time()
|
||||||
time_temp = time1
|
time_temp = time1
|
||||||
data_count_temp = 0
|
data_count_temp = 0
|
||||||
with open(file_name, "wb") as f:
|
with open(download_path+file_name, "wb") as f:
|
||||||
for i in down.iter_content(1024):
|
for i in down.iter_content(1024):
|
||||||
f.write(i)
|
f.write(i)
|
||||||
done_block = int((data_count / content_size) * 50)
|
done_block = int((data_count / content_size) * 50)
|
||||||
|
|
@ -731,7 +740,7 @@ if __name__ == "__main__":
|
||||||
# print(pan.list[int(command) - 1])
|
# print(pan.list[int(command) - 1])
|
||||||
name = pan.list[int(command) - 1]["FileName"]
|
name = pan.list[int(command) - 1]["FileName"]
|
||||||
print(name + " " + size_print_show)
|
print(name + " " + size_print_show)
|
||||||
print("press 1 to download now: ", end="")
|
print("输入1开始下载: ", end="")
|
||||||
sure = input()
|
sure = input()
|
||||||
if sure == "1":
|
if sure == "1":
|
||||||
pan.download(int(command) - 1)
|
pan.download(int(command) - 1)
|
||||||
|
|
@ -740,6 +749,12 @@ if __name__ == "__main__":
|
||||||
if int(command[9:]) > len(pan.list) or int(command[9:]) < 1:
|
if int(command[9:]) > len(pan.list) or int(command[9:]) < 1:
|
||||||
print("输入错误")
|
print("输入错误")
|
||||||
continue
|
continue
|
||||||
|
if pan.list[int(command[9:]) - 1]["Type"] == 1:
|
||||||
|
print(pan.list[int(command[9:]) - 1]["FileName"])
|
||||||
|
print("将打包下载文件夹,输入1开始下载:", end="")
|
||||||
|
sure = input()
|
||||||
|
if sure != "1":
|
||||||
|
continue
|
||||||
pan.download(int(command[9:]) - 1)
|
pan.download(int(command[9:]) - 1)
|
||||||
else:
|
else:
|
||||||
print("输入错误")
|
print("输入错误")
|
||||||
|
|
|
||||||
|
|
@ -655,8 +655,8 @@ class Pan123:
|
||||||
pass_word = text["passWord"]
|
pass_word = text["passWord"]
|
||||||
authorization = text["authorization"]
|
authorization = text["authorization"]
|
||||||
|
|
||||||
except FileNotFoundError or json.decoder.JSONDecodeError:
|
except:
|
||||||
print("read failed")
|
print("获取配置失败,重新登录")
|
||||||
|
|
||||||
if user_name == "" or pass_word == "":
|
if user_name == "" or pass_word == "":
|
||||||
if input_pwd:
|
if input_pwd:
|
||||||
Loading…
Reference in New Issue
Block a user