kushidou / bili-notice-hoshino

一个Hoshinobot插件,可以获得B站up主最新的动态并推送到QQ群中。
MIT License
65 stars 7 forks source link

正常使用几天后报错UnicodeEncodeError: 'gbk' codec can't encode character '\u200b' in position 256: illegal multibyte sequence #36

Closed FanJZSS closed 9 months ago

FanJZSS commented 9 months ago
[2024-02-02 23:30:13,179 b站动态监视器] ERROR: <class 'UnicodeEncodeError'> occured when doing scheduled job bili_watch.
[2024-02-02 23:30:13,179 b站动态监视器] ERROR: 'gbk' codec can't encode character '\u200b' in position 256: illegal multibyte sequence
Traceback (most recent call last):
  File "D:\QQ-Bot\HoshinoBot_Blue\hoshino\modules\bili-notice-hoshino\res\drawCard.py", line 45, in __init__
    self.card["origin"] = json.loads(self.card["origin"])
KeyError: 'origin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\QQ-Bot\HoshinoBot_Blue\hoshino\service.py", line 350, in wrapper
    ret = await func()
  File "D:\QQ-Bot\HoshinoBot_Blue\hoshino\modules\bili-notice-hoshino\bili_notice_hoshino.py", line 72, in bili_watch
    rst, dylist = await dymgr.get_update()
  File "D:\QQ-Bot\HoshinoBot_Blue\hoshino\modules\bili-notice-hoshino\dymgr.py", line 303, in get_update
    dynamic = drawCard.Card(card)
  File "D:\QQ-Bot\HoshinoBot_Blue\hoshino\modules\bili-notice-hoshino\res\drawCard.py", line 57, in __init__
    json.dump(dylist, f, ensure_ascii=False)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 180, in dump
    fp.write(chunk)
UnicodeEncodeError: 'gbk' codec can't encode character '\u200b' in position 256: illegal multibyte sequence

感觉是关注的动态有特殊字符的问题?

kushidou commented 9 months ago

初步看起来是json采用系统默认的GBK解码出现问题,实际上应该使用utf-8。检查了一遍代码,这是唯一一个没有指定utf-8的地方 image

FanJZSS commented 9 months ago

初步看起来是json采用系统默认的GBK解码出现问题,实际上应该使用utf-8。检查了一遍代码,这是唯一一个没有指定utf-8的地方 image

drawCard.py第58行少了个, 0

kushidou commented 9 months ago

6,忙中出错了