Fixed a windows filename bug. Fixed bug where item does not have a web url

This commit is contained in:
Eddy Hintze 2020-01-19 20:31:00 -05:00
parent 1d3ae04a60
commit b0a06d8bc0
3 changed files with 14 additions and 4 deletions

View File

@ -1,5 +1,11 @@
# Change log # Change log
### 0.0.7
- Replace `:` with ` -` in filenames
- Ignore items that do not have a web url
### 0.0.6 ### 0.0.6
- Started change log - Started change log
- Added more detail to readme - Added more detail to readme

View File

@ -1 +1 @@
__version__ = '0.0.6' __version__ = '0.0.7'

View File

@ -8,9 +8,9 @@ logger = logging.getLogger(__name__)
def _clean_name(dirty_str): def _clean_name(dirty_str):
allowed_chars = (' ', '_', '.', '-', ':', '[', ']') allowed_chars = (' ', '_', '.', '-', '[', ']')
clean = [] clean = []
for c in dirty_str.replace('+', '_'): for c in dirty_str.replace('+', '_').replace(':', ' -'):
if c.isalpha() or c.isdigit() or c in allowed_chars: if c.isalpha() or c.isdigit() or c in allowed_chars:
clean.append(c) clean.append(c)
@ -61,7 +61,11 @@ def download_library(cookie_path, library_path, progress_bar=False):
# Download each file type of a product # Download each file type of a product
for file_type in download_type['download_struct']: for file_type in download_type['download_struct']:
try:
url = file_type['url']['web'] url = file_type['url']['web']
except KeyError:
logger.info("No url found for " + item_title)
continue
ext = url.split('?')[0].split('.')[-1] ext = url.split('?')[0].split('.')[-1]
file_title = item_title + "." + ext file_title = item_title + "." + ext
filename = os.path.join(item_folder, file_title) filename = os.path.join(item_folder, file_title)