Commonists / CommonsDownloader

Tool to download thumbnails of files from Wikimedia Commons
MIT License
28 stars 16 forks source link

Download fails for file "C'est là le moulin?.JPG" #8

Open edouardhue opened 10 years ago

edouardhue commented 10 years ago

Log is:

INFO:root:Downloading C'est_l+á_le_moulin?.JPG with width 99999
INFO:root:Requested width is bigger than source - downloading full size
Traceback (most recent call last):
  File "C:\Python27\Scripts\download_from_Wikimedia_Commons-script.py", line 9, in <module>
    load_entry_point('CommonsDownloader==0.2', 'console_scripts', 'download_from_Wikimedia_Commons')()
  File "build\bdist.win32\egg\commonsdownloader\commonsdownloader.py", line 85, in main
  File "build\bdist.win32\egg\commonsdownloader\commonsdownloader.py", line 27, in download_from_file_list
  File "build\bdist.win32\egg\commonsdownloader\thumbnaildownload.py", line 122, in download_file
IOError: [Errno 22] invalid mode ('wb') or filename: ".\\Pictures\\C'est_l\xc3\xa0_le_moulin?.jpg"

Running @symac's patched version with Python 2.7.8 in PowerShell in Windows 8.1 Pro N. Issue seems to be caused by NTFS / Windows not supporting "?" in filenames.

JeanFred commented 9 years ago

With the proper exception handling introduced in 7dad7e6 and 3e1c728, the severity of this is mitigated since 1. CommonsDownloader will no longer crash when such a problem occurs 2/ The incident will be logged and notified to the user.

JeanFred commented 9 years ago

Digging more, I have not unearthed any obvious way to filter Windows forbidden characters in Python. Sounds like such a thing should exist though.