mirror of
https://github.com/gryf/slack-backup.git
synced 2025-12-17 03:20:25 +01:00
File extension rework for downloaded files
This commit is contained in:
@@ -60,7 +60,7 @@ class Download(object):
|
||||
self._hier_created = False
|
||||
self.cookies = {}
|
||||
|
||||
def download(self, url, filetype):
|
||||
def download(self, url, filetype, ext=None):
|
||||
"""
|
||||
Download asset, return local path to it
|
||||
"""
|
||||
@@ -68,7 +68,7 @@ class Download(object):
|
||||
if not self._hier_created:
|
||||
self._create_assets_dir()
|
||||
|
||||
filepath = self.get_filepath(url, filetype)
|
||||
filepath = self.get_filepath(url, filetype, ext)
|
||||
temp_file = utils.get_temp_name()
|
||||
|
||||
self._download(url, temp_file)
|
||||
@@ -95,7 +95,7 @@ class Download(object):
|
||||
|
||||
self._hier_created = True
|
||||
|
||||
def get_filepath(self, url, filetype):
|
||||
def get_filepath(self, url, filetype, ext=None):
|
||||
"""Get full path and filename for the file"""
|
||||
|
||||
typemap = {'avatar': self._images,
|
||||
@@ -123,6 +123,9 @@ class Download(object):
|
||||
utils.makedirs(os.path.join(path, part))
|
||||
path = os.path.join(path, part)
|
||||
|
||||
if ext and not fname.endswith(ext):
|
||||
fname = fname + "." + ext
|
||||
|
||||
return os.path.join(path, fname)
|
||||
|
||||
def calculate_new_filename(self, path, filetype):
|
||||
|
||||
Reference in New Issue
Block a user