Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

bt下载完毕hash时utf8解码错误 #291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pright
Copy link

@pright pright commented Jul 19, 2013

Hashing bt ...
Traceback (most recent call last):
File "/usr/bin/lixian_cli", line 64, in
execute_command()
File "/usr/bin/lixian_cli", line 61, in execute_command
commandscommand
File "/opt/xunlei-lixian/lixian_cli_parser.py", line 165, in parse
return f(parser(args_list, _args, *_kwargs))
File "/opt/xunlei-lixian/lixian_commands/download.py", line 296, in download_task
download_multiple_tasks(client, tasks, download_args)
File "/opt/xunlei-lixian/lixian_commands/download.py", line 208, in download_multiple_tasks
download_single_task(client, task, options)
File "/opt/xunlei-lixian/lixian_commands/download.py", line 190, in download_single_task
verified = lixian_hash_bt.verify_bt(output_path, lixian_hash_bt.bdecode(torrent_file)['info'], file_set=file_set, progress_callback=bar.update)
File "/opt/xunlei-lixian/lixian_hash_bt.py", line 244, in verify_bt
return verify_bt_multiple(path, info, file_set=file_set, progress_callback=progress_callback)
File "/opt/xunlei-lixian/lixian_hash_bt.py", line 169, in verify_bt_multiple
unicode_path = [p.decode(path_encoding) for p in x['path']]
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc3 in position 3: invalid continuation byte

@pright
Copy link
Author

pright commented Jul 19, 2013

发现问题是由于torrent info里面没有encoding,程序默认当作utf-8处理了,实际字符串是gbk。
加了下文件名编码检测,偷懒用了chardet库。

@xiamx
Copy link

xiamx commented Jul 19, 2013

Chardet好像不在stdlib里面,不知道iambus会不会收录

@pright
Copy link
Author

pright commented Jul 20, 2013

确实不在标准库里,不检测的话直接在decode的时候ignore好了,这样就是会跳过校验该文件。

@iambus
Copy link
Owner

iambus commented Jul 21, 2013

你方便把种子或者info hash发给我吗?

@pright
Copy link
Author

pright commented Jul 21, 2013

种子已发邮箱。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants