7sDream / torrent_parser

A .torrent file parser and creator for both Python 2 and 3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Same error with every torrent.

tejt99 opened this issue · comments

commented

Hi I was just having a look at this and I downloaded a test torrent using 'BitTorrent Now' and I got an error so I tried it on different files and I got the same one. It looks like this

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 290, in _next_string
string = raw.decode(encoding, self._error_handler)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pytp", line 10, in
sys.exit(__main())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 633, in __main
target_file, not args.dict, args.coding, args.errors
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 202, in parse
data = self._next_element()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 350, in _next_element
element = self._type_to_func(element_type)()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 254, in _next_dict
for key, element in self._dict_items_generator():
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 247, in _dict_items_generator
v = self._next_element(k)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 350, in _next_element
element = self._type_to_func(element_type)()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 254, in _next_dict
for key, element in self._dict_items_generator():
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 247, in _dict_items_generator
v = self._next_element(k)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 348, in _next_element
element = self._type_to_func(element_type)(field=field)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 306, in _next_string
''.join(msg)
torrent_parser.InvalidTorrentDataException: Fail to decode string at pos 1242 using encoding utf-8 when parser field "originator", maybe it is an hash field. You can use self.hash_field("originator") to let it be treated as hash value, so this error may disappear
USER-MacBook:torrent_parser-master USER$ sudo pytp 'FOOL'S GOLD DAY OFF FIRE.torrent'
-bash: unexpected EOF while looking for matching `''
-bash: syntax error: unexpected end of file
USER-MacBook:torrent_parser-master USER$ sudo pytp "FOOL'S GOLD DAY OFF FIRE.torrent"
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 290, in _next_string
string = raw.decode(encoding, self._error_handler)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pytp", line 10, in
sys.exit(__main())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 633, in __main
target_file, not args.dict, args.coding, args.errors
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 202, in parse
data = self._next_element()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 350, in _next_element
element = self._type_to_func(element_type)()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 254, in _next_dict
for key, element in self._dict_items_generator():
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 247, in _dict_items_generator
v = self._next_element(k)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 350, in _next_element
element = self._type_to_func(element_type)()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 254, in _next_dict
for key, element in self._dict_items_generator():
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 247, in _dict_items_generator
v = self._next_element(k)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 348, in _next_element
element = self._type_to_func(element_type)(field=field)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torrent_parser.py", line 306, in _next_string
''.join(msg)
torrent_parser.InvalidTorrentDataException: Fail to decode string at pos 1242 using encoding utf-8 when parser field "originator", maybe it is an hash field. You can use self.hash_field("originator") to let it be treated as hash value, so this error may disappear

I don't know if this is a known error. I assume the last error is the only informative one. This appears when using cli and as a module. I am running on mac OS python3.

Looks like your torrent file has a originator field which contains non-utf8 bytes.

If you are using the pytp CLI, try pytp some.torrent -e ignore.

If you are using this module in your code, try TorrentFileParse(f, errors="ignore").


Or you can upload your test torrent file so I can figure out what originator fields mean.

commented

Thanks