-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdl_stat.py
More file actions
41 lines (29 loc) · 962 Bytes
/
Copy pathdl_stat.py
File metadata and controls
41 lines (29 loc) · 962 Bytes
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
#-*- coding:utf-8 -*-
import os, io, sys, re
sys.path.append(".")
import dl_config
def isValideFile(path):
return True
def addPath(name, depth):
if not os.path.exists(dl_config.statPath):
ps.path.mkdir(dl_config.statPath)
filePath = dl_config.statPath + "/" + "downloaded_video.txt"
with open(filePath, "a+") as pf:
pf.write(name)
pf.write("\n")
return
def stat(rootPath, depth):
depth = depth + 1
for item in os.listdir(rootPath):
path = os.path.join(rootPath, item)
if os.path.isdir(path):
stat(path, depth)
elif os.path.isfile(path) and (os.path.splitext(path)[1] == ".mp4" or os.path.splitext(path)[1] == ".pdf"):
if isValideFile(path):
addPath(item, depth)
else:
pass
if __name__ == '__main__':
print("start")
stat(dl_config.basePath, 1)
print("finished")