Browse Source

updating the download path

master
manetta 4 years ago
parent
commit
192dbbc2a7
  1. 8
      LogBot/logbot.py

8
LogBot/logbot.py

@ -53,12 +53,12 @@ def download(message):
parsed_url = urlparse(message.url)
filename = os.path.basename(parsed_url.path).replace(' ','_').replace('%20','_') # safe url's
print('as the file: ', filename)
if not os.path.isdir(f'{ message.room }/{ media_type }'):
os.mkdir(f'{ message.room }/{ media_type }')
with open(f'{ message.room }/{ media_type }/{ filename }', 'wb') as media_file:
if not os.path.isdir(f'{ output }/{ message.room }/{ media_type }'):
os.mkdir(f'{ output }/{ message.room }/{ media_type }')
with open(f'{ output }/{ message.room }/{ media_type }/{ filename }', 'wb') as media_file:
media_file.write(data)
media_file.close()
# define media_post
media_path = f'{ media_type }/{ filename }'
if message.url.lower().endswith(('.jpg','jpeg','png','.gif','.bmp','.svg','eps')):

Loading…
Cancel
Save