diff --git a/setup.py b/setup.py index 5954809..18b3bea 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ 'click==7.0', 'google-api-python-client==1.6.3', 'requests==2.20.0', - 'python-slugify==1.2.6' + 'python-slugify==4.0.0' ] dev_requirements = [ diff --git a/src/downloader.py b/src/downloader.py index 58b3968..61e988c 100644 --- a/src/downloader.py +++ b/src/downloader.py @@ -1,4 +1,5 @@ import os +import re import sys import time @@ -23,7 +24,13 @@ class PacktConnectionError(ConnectionError): def slugify_product_name(title): """Return book title with spaces replaced by underscore and unicodes replaced by characters valid in filenames.""" - return slugify(title, separator='_', lowercase=False) + return slugify( + title, + separator='_', + lowercase=False, + regex_pattern=re.compile(r'[^-a-zA-Z0-9\+\#\.\-\–]+'), + replacements=[['–', '-']] + ) def wait_for_computation(predicate, timeout, retry_after):