Skip to content

Commit 1660f96

Browse files
committed
bug fix
1 parent 898cb5b commit 1660f96

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

gDriveCopyDownloader.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,30 @@ async def Check_clipboard_links(drive): #Only works for windows
6565
else:
6666
raise OSError("os isn't windows !")
6767
CF_HTML = win32clipboard.RegisterClipboardFormat("HTML Format")
68+
cacheClipboard = ""
6869
while 1:
70+
await asyncio.sleep(1)
6971
win32clipboard.OpenClipboard(0)
70-
src = win32clipboard.GetClipboardData(CF_HTML)
72+
try:
73+
src = win32clipboard.GetClipboardData(CF_HTML).decode("UTF-8")
74+
except TypeError:#if not html
75+
try:
76+
src = win32clipboard.GetClipboardData(win32clipboard.CF_TEXT).decode("UTF-8")
77+
except TypeError:
78+
src = ""
7179
win32clipboard.CloseClipboard()
72-
src = src.decode("UTF-8")
73-
Copy_dwnld_from_links(src, drive)
74-
75-
await asyncio.sleep(1)
80+
if(src != cacheClipboard): #avoid downloading infinite loop if still in clipboard
81+
cacheClipboard = src
82+
Copy_dwnld_from_links(src, drive)
7683

7784
print(" Some infos : \n"
7885
"You can put the links directly from google drive ('https://drive.google.com') but also those behind a "
7986
"redirection(like the one from igg).\n"
8087
"Temporary files in google drive of your download will be stored on 'Temp folder for script', you can delete it "
8188
"after the downloads. \n"
8289
"Settings are stored in the config.ini file.\n"
83-
"If you want to put the google drive folder in a custom folder(for example if you want to use a team drive), "
84-
"edit the FolderId field in config.ini and replace 'root' with the google drive folder id. \n"
90+
"If you want to put the google drive folder in a custom folder(to use your google team account), "
91+
"edit the FolderId field in config.ini and replace 'root' with the google drive team folder id.\n"
8592
"If you use Windows, you can go on config.ini and change ClipboardDetection to ClipboardDetection=1,"
8693
"you just have to Ctrl+C the links to download and it should handle the rest.\n"
8794
"The download percentage status is updated about every 100 MB, so wait a little if it appears to be stuck.\n"

gDriveLibrary.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def get_Gdrive_folder_id(drive, driveService, name, parent="root"): # return ID
1919
}
2020
query = "title='Temp folder for script' and mimeType='application/vnd.google-apps.folder'" \
2121
" and '" + parent + "' in parents and trashed=false"
22+
if parent != "root":
23+
query += "and driveId='" + parent + "' and includeItemsFromAllDrives=true and supportsAllDrives = true"
2224
listFolders = drive.ListFile({'q': query})
2325
for subList in listFolders:
2426
if subList == []: # if folder doesn't exist, create it

0 commit comments

Comments
 (0)