louist87 / Scrappy

Python module to rename media collections based on scrapes from thetvdb.com. CLI and GUI tools, too!
27 stars 0 forks source link

Formatter choking on unicode data #5

Closed louist87 closed 11 years ago

louist87 commented 11 years ago
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/scrappy/scrappy.py", line 96, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/scrappy/scrappy.py", line 85, in main
    autoscrape()
  File "/usr/local/lib/python2.7/dist-packages/scrappy/scrappy.py", line 53, in autoscrape
    _execute_scrape(thresh, path, kwargs, coms)
  File "/usr/local/lib/python2.7/dist-packages/scrappy/scrappy.py", line 80, in _execute_scrape
    s.rename_files(test=coms['test'])
  File "/usr/local/lib/python2.7/dist-packages/scrappy/core.py", line 245, in rename_files
    newname = '{0}.{ext}'.format(formatter(ep), ext=fname.split('.')[-1])
  File "/usr/local/lib/python2.7/dist-packages/scrappy/formatters.py", line 27, in __call__
    return self.format.format(**dict(arg_pairs))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 6: ordinal not in range(128)
minus7 commented 11 years ago

Something probably isn't unicode, try setting the encoding of the python files to utf-8. just add '# coding=utf-8' after the shebang.

louist87 commented 11 years ago

@minus7, I did a quck google search and saw that people usually used # -*- coding: utf-8 -*-. I'm guessing it's the same thing, but I thought I'd ask just to be sure. It's the same thing, right?

minus7 commented 11 years ago

Yes, Python accepts various ways to set the encoding like that. I think there just has to be the word coding and the encoding there.

louist87 commented 11 years ago

Fixed. Thanks for your contribution!