From 09564f17483219920cae0f383eff5207137d3a60 Mon Sep 17 00:00:00 2001
From: JerryYan <792602257@qq.com>
Date: Thu, 23 Apr 2020 20:55:25 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A5=BF=E7=93=9C=E5=8F=88=E5=8D=87=E7=BA=A7?=
 =?UTF-8?q?=E4=BA=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Struct/User.py |  8 ++++++--
 WinMain.py     |  6 ------
 api.py         | 15 +++++++++------
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/Struct/User.py b/Struct/User.py
index c01b722..d58acf8 100644
--- a/Struct/User.py
+++ b/Struct/User.py
@@ -41,13 +41,17 @@ class User:
                 self.type = json["extra"]["user_room_auth_status"]["user_type"]
                 self.block = json["extra"]["user_room_auth_status"]["is_block"]
                 self.mute = json["extra"]["user_room_auth_status"]["is_silence"]
-        elif "user_info" in json and json["user_info"] is not None:
+        if "user_info" in json and json["user_info"] is not None:
                 self.ID = json['user_info']['user_id']
                 self.name = json['user_info']['name']
-        elif "anchor" in json and json["anchor"] is not None:
+        if "anchor" in json and json["anchor"] is not None:
             if "user_info" in json["anchor"] and json["anchor"]['user_info'] is not None:
                 self.ID = json["anchor"]['user_info']['user_id']
                 self.name = json["anchor"]['user_info']['name']
+        if "user_id" in json:
+            self.ID = json["user_id"]
+        if "user_name" in json:
+            self.name = json["user_name"]
         if self.type is None:
             self.type = 0
         if isinstance(self.level, str):
diff --git a/WinMain.py b/WinMain.py
index 8f7b372..56a0c32 100644
--- a/WinMain.py
+++ b/WinMain.py
@@ -192,12 +192,6 @@ if __name__ == "__main__":
     resetColor()
     print("西瓜直播礼物助手 by JerryYan")
     print("接口版本8.1.6")
-    if len(sys.argv) > 1:
-        name = sys.argv[1]
-        if len(sys.argv) > 2:
-            SHOW_ALL = sys.argv[2] == "a"
-    else:
-        name = readInput("请输入主播用户名,默认为", name, 3)
     print("搜索【", name, "】", end="\t", flush=True)
     api = WinMain(name)
     if not api.isValidUser:
diff --git a/api.py b/api.py
index f091bcf..c383f21 100644
--- a/api.py
+++ b/api.py
@@ -256,16 +256,19 @@ class XiGuaLiveApi:
             for i in d["data"]:
                 if self.broadcaster is not None:
                     break
-                if i["block_type"] != 0:
+                if i["block_type"] != 2:
                     continue
                 if "cells" not in i or len(i["cells"]) == 0:
                     break
                 for _j in i["cells"]:
-                    _user = User(_j)
-                    if self._checkUsernameIsMatched(_user):
-                        self.isValidUser = True
-                        self.broadcaster = _user
-                        break
+                    if "room" in _j:
+                        _user = User(_j["room"])
+                        self.roomID = _j["room"]["room_id"]
+                        self.isLive = _j["room"]["is_living"]
+                        if self._checkUsernameIsMatched(_user):
+                            self.isValidUser = True
+                            self.broadcaster = _user
+                            break
         self._updRoomAt = datetime.now()
         return self._updateUserInfo()