hylarucoder / danmu.fm

douyutv danmu 斗鱼TV 弹幕助手
310 stars 76 forks source link

KeyError: 'room_gg' #14

Closed yutiansut closed 7 years ago

yutiansut commented 7 years ago

[21:42:58] INFO::danmu - 正在检查环境 [21:42:58] INFO::danmu - 程序正在启动,检查环境配置 [21:42:58] INFO::danmu - 开始配置环境 [21:42:58] INFO::danmu - 环境检查完毕,正在开启斗鱼客户端(请等待15s~30s) Traceback (most recent call last): File "/usr/local/bin/danmu.fm", line 11, in sys.exit(main()) File "/usr/local/lib/python3.6/dist-packages/danmufm/danmu.py", line 117, in main parse_command() File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 722, in call return self.main(args, kwargs) File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 535, in invoke return callback(args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/danmufm/danmu.py", line 107, in parse_command start_douyu_client() File "/usr/local/lib/python3.6/dist-packages/danmufm/danmu.py", line 112, in start_douyu_client DouyuClient(url).start() File "/usr/local/lib/python3.6/dist-packages/danmufm/client/douyu_client.py", line 51, in start auth_server_ip, auth_server_port = self.fetch_room_info(self.url) File "/usr/local/lib/python3.6/dist-packages/danmufm/client/douyu_client.py", line 75, in fetch_room_info room["gg_show"] = js["room_gg"]["show"] KeyError: 'room_gg'

jiaminxu commented 7 years ago

试了一下也有相同问题。KeyError: 'room_gg'

CBQu commented 7 years ago

我也是这个问题,求大神解决……

hylarucoder commented 7 years ago

你好,问题出在解析json的地方. 由于斗鱼的网页经过几次比较大的调整,可能原有的api就失效了.需要寻找新API

littlewrite commented 7 years ago

说一下简单粗暴点的解决方案吧。 打开文件: /usr/local/lib/python3.6/dist-packages/danmufm/client/douyu_client.py ,为该文件添加几行注释,这是添加后的代码。

if room_info_json_format != False and auth_server_json_format != False:
    js = room_info_json_format
    room = room_status
    room["id"] = js["room_id"]
    room["name"] = js["room_name"]
#    room["gg_show"] = js["room_gg"]["show"]
    room["owner_uid"] = js["owner_uid"]
    room["owner_name"] = js["owner_name"]
    room["room_url"] = js["room_url"]
#    room["near_show_time"] = js["near_show_time"]
    room["tags"] = []
    room_tags_json = js["all_tag_list"]
#    if js["room_tag_list"] != None:
#        room_tags_size = len(js["room_tag_list"])
#        for i in range(0, room_tags_size):
#            room["tags"].append(room_tags_json[js["room_tag_list"][i]]["name"])