bitbybyte / fantiadl

Download posts and media from Fantia
MIT License
300 stars 51 forks source link

Handle terminal encoding on output #27

Closed tenyuhuang closed 4 years ago

tenyuhuang commented 4 years ago

Hi, I'm using the latest build of fantiadl and encountered this issue:

Encountered an error downloading URL. Skipping...
Traceback (most recent call last):
  File "fantiadl.py", line 88, in <module>
    downloader.download_fanclub(fanclub, cmdl_opts.limit)
  File "F:\fantia\models.py", line 142, in download_fanclub
    self.download_fanclub_metadata(fanclub)
  File "F:\fantia\models.py", line 122, in download_fanclub_metadata
    self.perform_download(header_url, header_filename, server_filename=self.use_server_filenames)
  File "F:\fantia\models.py", line 210, in perform_download
    self.output("File: {}\n".format(filename))
  File "F:\fantia\models.py", line 68, in output
    sys.stdout.write(output)
UnicodeEncodeError: 'gbk' codec can't encode character '\u2615' in position 8: illegal multibyte sequence

Seems like there is no exception mechanism when a filename contains illegal characters in a certain charset. Would be really appreciated if filenames with illegal characters can be automatically renamed / normalized.

Could you look into the issue? Thank you very much!

bitbybyte commented 4 years ago

@tenyuhuang Just FYI, your log included your credentials so I edited them out and deleted the revision. I'd consider changing your pass.