52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
![]() |
#!/usr/bin/env python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
import argparse
|
||
|
from p115 import P115Client, P115FileSystem
|
||
|
import time
|
||
|
import traceback
|
||
|
|
||
|
count=0
|
||
|
|
||
|
def walk_dir(fs,f):
|
||
|
dirlist=list()
|
||
|
file_list = fs.listdir_attr()
|
||
|
for file_obj in file_list:
|
||
|
if not file_obj.is_directory:
|
||
|
print(file_obj.path+"\t"+str(file_obj.size))
|
||
|
f.write(file_obj.path+"\t"+str(file_obj.size)+"\n")
|
||
|
f.flush()
|
||
|
else:
|
||
|
dirlist.append(file_obj.path)
|
||
|
for dirItem in dirlist:
|
||
|
fs.chdir(dirItem)
|
||
|
global count
|
||
|
count=count+1
|
||
|
if count%4==0:
|
||
|
time.sleep(1)
|
||
|
walk_dir(fs,f)
|
||
|
return
|
||
|
|
||
|
def main():
|
||
|
parser = argparse.ArgumentParser(description='快速遍历115分享目录')
|
||
|
parser.add_argument('--cookie', type=str, required=True, help='115Cookie')
|
||
|
parser.add_argument('--url', type=str, required=True, help='115ShareUrl')
|
||
|
parser.add_argument('--output', type=str, required=True, help='outputfile')
|
||
|
args = parser.parse_args()
|
||
|
cookie=args.cookie
|
||
|
shareUrl=args.url
|
||
|
client=P115Client(cookie)
|
||
|
|
||
|
if not shareUrl.startswith("http"):
|
||
|
shareUrl = "https://115.com/s/" + shareUrl
|
||
|
|
||
|
print("cookie:"+args.cookie+", shareurl:"+shareUrl)
|
||
|
fs = client.get_share_fs(shareUrl)
|
||
|
|
||
|
count=0
|
||
|
f=open(args.output, mode="a", encoding="utf-8")
|
||
|
walk_dir(fs,f)
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|