1good = {"rar", "zip", "r00"}
2for root, dirs, files in os.walk(path):
3 if not any(f.endswith(".mkv") for f in files):
4 tmp = {"rar": [], "zip": []}
5 for file in files:
6 ext = file[-4:]
7 if ext == ".mkv":
8 break
9 elif ext in good:
10 tmp[ext].append(join(root, file))
11 else:
12 for p in tmp.get(".zip", []):
13 print("Unzipping ", p, "...")
14 check_call(["unzip", p, "-d", root])
15 for p in tmp.get(".rar", []):
16 check_call(["unrar", "e", p, root])
17
1for root, dirs, files in os.walk(path):
2 if not any(f.endswith(".mkv") for f in files):
3 for file in files:
4 pth = join(root, file)
5 if file.endswith("zip"):
6 print("Unzipping ",file, "...")
7 check_call(["unzip" , pth, "-d", root])
8 elif file.endswith((".rar",".r00")):
9 check_call(["unrar","e", pth, root])
10