Skip to content

Commit

Permalink
Fixed DISABLE_DRIVE_LINK for /list
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawn India authored and junedkh committed May 1, 2023
1 parent cebe70c commit 1bc321d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bot/helper/mirror_utils/upload_utils/gdriveTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,34 +586,36 @@ def drive_list(self, fileName, stopDup=False, noMulti=False, isRecursive=True, i
if mime_type == "application/vnd.google-apps.folder":
furl = f"https://drive.google.com/drive/folders/{file.get('id')}"
msg += f"📁 <code>{file.get('name')}<br>(folder)</code><br>"
msg += f"<b><a href={furl}>Drive Link</a></b>"
if not config_dict['DISABLE_DRIVE_LINK']:
msg += f"<b><a href={furl}>Drive Link</a></b> | "
if index_url:
if isRecur:
url_path = "/".join([rquote(n, safe='')
for n in self.__get_recursive_list(file, dir_id)])
else:
url_path = rquote(f'{file.get("name")}', safe='')
url = f'{index_url}/{url_path}/'
msg += f' <b>| <a href="{url}">Index Link</a></b>'
msg += f'<b><a href="{url}">Index Link</a></b>'
elif mime_type == 'application/vnd.google-apps.shortcut':
furl = f"https://drive.google.com/drive/folders/{file.get('id')}"
msg += f"⁍<a href='https://drive.google.com/drive/folders/{file.get('id')}'>{file.get('name')}" \
f"</a> (shortcut)"
else:
furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download"
msg += f"📄 <code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size', 0)))})</code><br>"
msg += f"<b><a href={furl}>Drive Link</a></b>"
if not config_dict['DISABLE_DRIVE_LINK']:
msg += f"<b><a href={furl}>Drive Link</a></b> | "
if index_url:
if isRecur:
url_path = "/".join(rquote(n, safe='')
for n in self.__get_recursive_list(file, dir_id))
else:
url_path = rquote(f'{file.get("name")}')
url = f'{index_url}/{url_path}'
msg += f' <b>| <a href="{url}">Index Link</a></b>'
msg += f'<b><a href="{url}">Index Link</a></b>'
if mime_type.startswith(('image', 'video', 'audio')):
urlv = f'{index_url}/{url_path}?a=view'
msg += f' <b>| <a href="{urlv}">View Link</a></b>'
msg += f' | <b><a href="{urlv}">View Link</a></b>'
msg += '<br><br>'
contents_no += 1
if len(msg.encode('utf-8')) > 39000:
Expand Down

0 comments on commit 1bc321d

Please sign in to comment.