Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
anasty17
GitHub Repository: anasty17/mirror-leech-telegram-bot
Path: blob/master/driveid.py
1625 views
1
import os
2
import re
3
4
print(
5
"\n\n"
6
" Bot can search files recursively, but you have to add the list of drives you want to search.\n"
7
" Use the following format: (You can use 'root' in the ID in case you wan to use main drive.)\n"
8
" teamdrive NAME --> anything that you likes\n"
9
" teamdrive ID --> id of teamdrives in which you likes to search ('root' for main drive)\n"
10
" teamdrive INDEX URL --> enter index url for this drive.\n"
11
" go to the respective drive and copy the url from address bar\n"
12
)
13
msg = ""
14
if os.path.exists("list_drives.txt"):
15
with open("list_drives.txt", "r+") as f:
16
lines = f.read()
17
if not re.match(r"^\s*$", lines):
18
print(lines)
19
print(
20
"\n\n"
21
" DO YOU WISH TO KEEP THE ABOVE DETAILS THAT YOU PREVIOUSLY ADDED???? ENTER (y/n)\n"
22
" IF NOTHING SHOWS ENTER n"
23
)
24
while 1:
25
choice = input()
26
if choice in ["y", "Y"]:
27
msg = f"{lines}"
28
break
29
elif choice in ["n", "N"]:
30
break
31
else:
32
print(
33
"\n\n DO YOU WISH TO KEEP THE ABOVE DETAILS ???? y/n <=== this is option ..... OPEN YOUR EYES & READ..."
34
)
35
num = int(input(" How Many Drive/Folder You Likes To Add : "))
36
for count in range(1, num + 1):
37
print(f"\n > DRIVE - {count}\n")
38
name = input(" Enter Drive NAME (anything) : ")
39
id = input(" Enter Drive ID : ")
40
index = input(" Enter Drive INDEX URL (optional) : ")
41
if not name or not id:
42
print("\n\n ERROR : Dont leave the name/id without filling.")
43
exit(1)
44
name = name.replace(" ", "_")
45
if index:
46
if index[-1] == "/":
47
index = index[:-1]
48
else:
49
index = ""
50
msg += f"{name} {id} {index}\n"
51
with open("list_drives.txt", "w") as file:
52
file.truncate(0)
53
file.write(msg)
54
print("\n\n Done!")
55
56