更新文件: getwebdavlist.exe, webdav_simulator.arm64, getalist.exe, getwebdavlist.py, webdav_simulator.amd64 等13个文件

This commit is contained in:
ZJP Monitor
2025-05-17 13:33:47 +08:00
parent 0856fadedc
commit 899361ed79
13 changed files with 268 additions and 13 deletions

View File

@ -6,11 +6,29 @@ from webdav3.client import Client
import os
import time
import re
import sys
import traceback
count=0
failcount=0
def walk(client, current_path="/", output_file=None, replaceroot=None):
items=client.list(current_path)
fullscan=True
def walk(client, current_path="/", output_file=None, replaceroot=None, lastpath=None):
global failcount
try:
items=client.list(current_path)
failcount=0
except KeyboardInterrupt:
print("get ctrl+c, exit")
sys.exit(1)
except:
traceback.print_exc()
time.sleep(1)
failcount+=1
if failcount>10:
sys.exit(1)
return
filetype_re=re.compile(r'\.(png|jpg|jpeg|bmp|gif|doc|nfo|flac|mp3|wma|ape|cue|wav|dst|dff|dts|ac3|eac3|txt)$')
# print(items)
for item in items[1:]:
@ -20,15 +38,28 @@ def walk(client, current_path="/", output_file=None, replaceroot=None):
is_dir = full_path.endswith("/")
except:
continue
global fullscan
# print(f"fullscan:{fullscan}, full_path:{full_path}, lastpath:{lastpath}")
if is_dir: # 判断是否为目录
#global count
#count=count+1
#if count%4==0:
# time.sleep(1)
if not fullscan and not full_path in lastpath:
continue
if full_path == lastpath:
fullscan = True
try:
walk(client, full_path, output_file, replaceroot)
walk(client, full_path, output_file, replaceroot, lastpath)
except KeyboardInterrupt:
print("get ctrl+c, exit")
sys.exit(1)
except:
time.sleep(1)
#sys.exit(1)
pass
elif not fullscan:
continue
else:
if filetype_re.search(full_path) != None or "BDMV" in full_path:
continue
@ -41,6 +72,7 @@ def walk(client, current_path="/", output_file=None, replaceroot=None):
print(f"{full_path}\t{size}")
if output_file != None:
output_file.write(f"{full_path}\t{size}\n")
output_file.flush()
from urllib.parse import urlparse
@ -62,7 +94,8 @@ def main():
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('--output', type=str, required=True, help='输出文件')
parser.add_argument('--lastpath', type=str, default=None, required=False, help='最后扫到的路径(从此开始继续)')
parser.add_argument('--replaceroot', type=str, default=None, required=False, help='替换根目录名称')
args = parser.parse_args()
@ -80,8 +113,26 @@ def main():
client = Client(options)
print("WebDAV URL:", args.url)
if args.lastpath == None:
try:
with open(args.output, "r", encoding="utf-8") as f:
tmplines = f.readlines()
for i in range(len(tmplines)-1, -1, -1):
line=tmplines[i].strip()
if line != None and line != "":
args.lastpath = os.path.dirname(line.split("\t")[0])
break
except:
traceback.print_exc()
output_file = open(args.output, mode="a", encoding="utf-8")
walk(client, path, output_file,args.replaceroot)
if args.lastpath != None and args.lastpath != "":
global fullscan
fullscan = False
if args.lastpath != None:
if not args.lastpath.endswith("/"):
args.lastpath = args.lastpath+"/"
print(f"lastpath:{args.lastpath}")
walk(client, path, output_file,args.replaceroot, args.lastpath)
output_file.close()
if __name__ == '__main__':