replace illegal characters in paths
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import importlib
|
import importlib
|
||||||
from . import config, extractor
|
from . import config, extractor, text
|
||||||
from .extractor.common import Message
|
from .extractor.common import Message
|
||||||
|
|
||||||
class DownloadManager():
|
class DownloadManager():
|
||||||
@@ -85,7 +85,7 @@ class DownloadJob():
|
|||||||
def download(self, msg):
|
def download(self, msg):
|
||||||
"""Download the resource specified in 'msg'"""
|
"""Download the resource specified in 'msg'"""
|
||||||
_, url, metadata = msg
|
_, url, metadata = msg
|
||||||
filename = self.filename_fmt.format(**metadata)
|
filename = text.clean_path(self.filename_fmt.format(**metadata))
|
||||||
path = os.path.join(self.directory, filename)
|
path = os.path.join(self.directory, filename)
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
self.print_skip(path)
|
self.print_skip(path)
|
||||||
@@ -99,7 +99,9 @@ class DownloadJob():
|
|||||||
"""Set and create the target directory for downloads"""
|
"""Set and create the target directory for downloads"""
|
||||||
self.directory = os.path.join(
|
self.directory = os.path.join(
|
||||||
self.mngr.get_base_directory(),
|
self.mngr.get_base_directory(),
|
||||||
self.directory_fmt.format(**msg[1])
|
self.directory_fmt.format(**{
|
||||||
|
key: text.clean_path(value) for key, value in msg[1].items()
|
||||||
|
})
|
||||||
)
|
)
|
||||||
os.makedirs(self.directory, exist_ok=True)
|
os.makedirs(self.directory, exist_ok=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user