vikstrous / pirate-get

A command line interface for The Pirate Bay
GNU Affero General Public License v3.0
337 stars 53 forks source link

UnicodeEncodeError #77

Closed giamat6 closed 8 years ago

giamat6 commented 8 years ago

Good morning, I've this error when I launch command 'pirate-get' (without any options):

UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 164: ordinal not in range(128)

This is the output of command:

Trying https://thepiratebay.mn... Failed Trying https://pirateproxy.pl... Ok Traceback (most recent call last): File "/usr/local/bin/pirate-get", line 9, in load_entry_point('pirate-get==0.2.8', 'console_scripts', 'pirate-get')() File "/usr/local/lib/python3.4/dist-packages/pirate/pirate.py", line 396, in main pirate_main(args) File "/usr/local/lib/python3.4/dist-packages/pirate/pirate.py", line 314, in pirate_main printer.search_results(results, local=args.source == 'local_tpb') File "/usr/local/lib/python3.4/dist-packages/pirate/print.py", line 95, in search_results self.print(table) File "/usr/local/lib/python3.4/dist-packages/pirate/print.py", line 38, in print return builtins.print(_args, *_kwargs)

UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 164: ordinal not in range(128)

I use pirate-get in raspberry pi running OSMC (variant of raspbian with kodi) and Python3.4.

I do not know how to solve this problem, also researched streams returns "no results".

rnhmjoj commented 8 years ago

The error is raised by print itself: I guess it's python which can't figure out your terminal encoding so it falls back plain ASCII and fails to print some UTF-8 character. Can you check?

rnhmjoj commented 8 years ago

I'm not sure what \xa0 is: it could be part of some color escape sequence. You can try to run pirate-get with --disable-colors

giamat6 commented 8 years ago

With option --disable-colors I've same problem. I'm googled a little bit and I've found a little workaround: with command "osmc@osmc$ PYTHONIOENCODING=utf-8 pirate-get" the script works perfectly.. :+1: I'll try to force my locale with UTF8 and I'll recheck without the envvar. Thanks for your explanation that allowed me to understand the specific problem.

rnhmjoj commented 8 years ago

No problem.