2021-11-23 09:35:16 +08:00
|
|
|
import os
|
|
|
|
import re
|
2023-11-06 08:05:22 +08:00
|
|
|
|
|
|
|
print(
|
|
|
|
"\n\n"
|
|
|
|
" Bot can search files recursively, but you have to add the list of drives you want to search.\n"
|
|
|
|
" Use the following format: (You can use 'root' in the ID in case you wan to use main drive.)\n"
|
|
|
|
" teamdrive NAME --> anything that you likes\n"
|
|
|
|
" teamdrive ID --> id of teamdrives in which you likes to search ('root' for main drive)\n"
|
|
|
|
" teamdrive INDEX URL --> enter index url for this drive.\n"
|
|
|
|
" go to the respective drive and copy the url from address bar\n"
|
|
|
|
)
|
|
|
|
msg = ""
|
|
|
|
if os.path.exists("list_drives.txt"):
|
|
|
|
with open("list_drives.txt", "r+") as f:
|
2021-11-23 09:35:16 +08:00
|
|
|
lines = f.read()
|
2023-11-06 08:05:22 +08:00
|
|
|
if not re.match(r"^\s*$", lines):
|
2021-11-23 09:35:16 +08:00
|
|
|
print(lines)
|
2023-11-06 08:05:22 +08:00
|
|
|
print(
|
|
|
|
"\n\n"
|
|
|
|
" DO YOU WISH TO KEEP THE ABOVE DETAILS THAT YOU PREVIOUSLY ADDED???? ENTER (y/n)\n"
|
|
|
|
" IF NOTHING SHOWS ENTER n"
|
|
|
|
)
|
2021-11-23 09:35:16 +08:00
|
|
|
while 1:
|
|
|
|
choice = input()
|
2023-11-06 08:05:22 +08:00
|
|
|
if choice in ["y", "Y"]:
|
|
|
|
msg = f"{lines}"
|
2021-11-23 09:35:16 +08:00
|
|
|
break
|
2023-11-06 08:05:22 +08:00
|
|
|
elif choice in ["n", "N"]:
|
2021-11-23 09:35:16 +08:00
|
|
|
break
|
|
|
|
else:
|
2023-04-05 09:30:28 +08:00
|
|
|
print(
|
2023-11-06 08:05:22 +08:00
|
|
|
"\n\n DO YOU WISH TO KEEP THE ABOVE DETAILS ???? y/n <=== this is option ..... OPEN YOUR EYES & READ..."
|
|
|
|
)
|
2021-11-23 09:35:16 +08:00
|
|
|
num = int(input(" How Many Drive/Folder You Likes To Add : "))
|
|
|
|
for count in range(1, num + 1):
|
|
|
|
print(f"\n > DRIVE - {count}\n")
|
2023-04-05 09:30:28 +08:00
|
|
|
name = input(" Enter Drive NAME (anything) : ")
|
|
|
|
id = input(" Enter Drive ID : ")
|
2021-11-23 09:35:16 +08:00
|
|
|
index = input(" Enter Drive INDEX URL (optional) : ")
|
|
|
|
if not name or not id:
|
|
|
|
print("\n\n ERROR : Dont leave the name/id without filling.")
|
|
|
|
exit(1)
|
2023-04-05 09:30:28 +08:00
|
|
|
name = name.replace(" ", "_")
|
2021-11-23 09:35:16 +08:00
|
|
|
if index:
|
|
|
|
if index[-1] == "/":
|
|
|
|
index = index[:-1]
|
|
|
|
else:
|
2023-11-06 08:05:22 +08:00
|
|
|
index = ""
|
2021-11-23 09:35:16 +08:00
|
|
|
msg += f"{name} {id} {index}\n"
|
2023-11-06 08:05:22 +08:00
|
|
|
with open("list_drives.txt", "w") as file:
|
2021-11-23 09:35:16 +08:00
|
|
|
file.truncate(0)
|
|
|
|
file.write(msg)
|
|
|
|
print("\n\n Done!")
|