更新文件: getwebdavlist.exe, webdav_simulator.arm64, xy.txt.xz, getwebdavlist.py, webdav_simulator.amd64 等9个文件
This commit is contained in:
BIN
getwebdavlist.exe
Normal file
BIN
getwebdavlist.exe
Normal file
Binary file not shown.
82
getwebdavlist.py
Normal file
82
getwebdavlist.py
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf- -*-
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
from webdav3.client import Client
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
count=0
|
||||||
|
|
||||||
|
def walk(client, current_path="/", output_file=None, replaceroot=None):
|
||||||
|
items=client.list(current_path)
|
||||||
|
for item in items[1:]:
|
||||||
|
full_path = f"{current_path}/{item}".replace("//", "/")
|
||||||
|
try:
|
||||||
|
is_dir = client.is_dir(full_path)
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
if is_dir: # 判断是否为目录
|
||||||
|
#global count
|
||||||
|
#count=count+1
|
||||||
|
#if count%4==0:
|
||||||
|
# time.sleep(1)
|
||||||
|
try:
|
||||||
|
walk(client, full_path, output_file, replaceroot)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
size = client.info(full_path).get('size', 0)
|
||||||
|
if replaceroot!=None:
|
||||||
|
if replaceroot=="":
|
||||||
|
full_path=os.path.join("/",*full_path.split("/")[2:])
|
||||||
|
else:
|
||||||
|
full_path=os.path.join("/",replaceroot,*full_path.split("/")[2:])
|
||||||
|
print(f"{full_path}\t{size}")
|
||||||
|
if output_file != None:
|
||||||
|
output_file.write(f"{full_path}\t{size}\n")
|
||||||
|
|
||||||
|
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
def extract_url_components(url):
|
||||||
|
"""分解 URL 为 schema(协议)、hostname(主机地址)、path(路径)"""
|
||||||
|
parsed = urlparse(url)
|
||||||
|
|
||||||
|
# 提取核心组件
|
||||||
|
schema = parsed.scheme or "http" # 默认协议处理
|
||||||
|
hostname = f"{parsed.hostname}:{parsed.port}" # 自动过滤端口和认证信息
|
||||||
|
path = parsed.path.rstrip('/') or '/' # 路径标准化
|
||||||
|
|
||||||
|
return schema, hostname, path
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description='快速遍历WebDAV目录')
|
||||||
|
parser.add_argument('--url', type=str, required=True, help='WebDAV URL')
|
||||||
|
parser.add_argument('--username', type=str, required=True, help='WebDAV username')
|
||||||
|
parser.add_argument('--password', type=str, required=True, help='WebDAV password')
|
||||||
|
parser.add_argument('--output', type=str, required=True, help='outputfile')
|
||||||
|
parser.add_argument('--replaceroot', type=str, default=None, required=False, help='替换根目录名称')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
schema, hostname, path = extract_url_components(args.url)
|
||||||
|
print(schema,hostname,path)
|
||||||
|
|
||||||
|
options = {
|
||||||
|
'webdav_hostname': schema+"://"+hostname,
|
||||||
|
'webdav_root': '/',
|
||||||
|
'webdav_login': args.username,
|
||||||
|
'webdav_password': args.password,
|
||||||
|
'disable_check': True, # 跳过 SSL 证书验证:ml-citation{ref="6" data="citationList"}
|
||||||
|
'disable_head': True, # 跳过 SSL 证书验证:ml-citation{ref="6" data="citationList"}
|
||||||
|
}
|
||||||
|
client = Client(options)
|
||||||
|
|
||||||
|
print("WebDAV URL:", args.url)
|
||||||
|
output_file = open(args.output, mode="a", encoding="utf-8")
|
||||||
|
walk(client, path, output_file,args.replaceroot)
|
||||||
|
output_file.close()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
2
run.bat
2
run.bat
@ -1,3 +1,3 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
webdav_simulator.exe --alist_config "http://192.168.1.2:5678/,,#http://192.168.1.3:5678,alist-1234-5678," xy115-all.txt.xz
|
webdav_simulator.exe --alist_config "http://192.168.1.2:5678/,,#http://192.168.1.3:5678,alist-1234-5678," "xy115-all.txt.xz#xy.txt.xz"
|
||||||
|
2
run.sh
2
run.sh
@ -18,4 +18,4 @@ cd "${progdir}"
|
|||||||
mkdir tmp
|
mkdir tmp
|
||||||
chmod 777 tmp
|
chmod 777 tmp
|
||||||
export TMPDIR=tmp
|
export TMPDIR=tmp
|
||||||
./webdav_simulator.amd64 --alist_config "http://192.168.1.2:5678,,#http://192.168.1.3:5678,alist-1234-5678," xy115-all.txt.xz
|
./webdav_simulator.amd64 --alist_config "http://192.168.1.2:5678,,#http://192.168.1.3:5678,alist-1234-5678," "xy115-all.txt.xz#xy.txt.xz"
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
xy115-all.txt.xz
BIN
xy115-all.txt.xz
Binary file not shown.
Reference in New Issue
Block a user