-
Notifications
You must be signed in to change notification settings - Fork 5
Unable to download file with improper name #3
Copy link
Copy link
Open
Description
This app automatically tries to name the downloaded files. The problem is if the original name contains invalid characters, for example "Week 2: Abc Def"
In Windows, this results in an error:
NotADirectoryError: [WinError 267] The directory name is invalid: 'Week 2: Intent and Premise'
(venv) PS C:\Users\vladi\Downloads\sprout_downloader_python> python .\sprout.py --help
C:\Users\vladi\Downloads\sprout_downloader_python\venv\Lib\site-packages\requests\__init__.py:89: RequestsDependencyWarning: urllib3 (2.3.0) or chardet (3.0.4) doesn't match a supported version!
warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Note: The error above is from the Python version of this script. It was easier to debug.
I fixed the issue temporarily like this:
# Remove the double quotes in the title name
title = data.get('title').replace('"', '')
# Remove (or replace) any invalid Windows filename characters
# This example replaces them with an underscore
title = re.sub(r'[<>:"/\\|?*]', '_', title)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels