不存在时的判断

This commit is contained in:
Jerry Yan 2020-01-09 09:27:41 +08:00
parent 6a2288a45d
commit bb5fa72f50

3
api.py
View File

@ -254,6 +254,7 @@ class XiGuaLiveApi:
print("搜索接口请求失败")
return False
self.broadcaster = None
self.isValidUser = False
if "data" in d and d["data"] is not None:
for i in d["data"]:
if self.broadcaster is not None:
@ -276,6 +277,7 @@ class XiGuaLiveApi:
:return:
"""
if self.broadcaster is None:
self.isValidUser = False
return False
_formatData = {"COMMON": COMMON_GET_PARAM, "TIMESTAMP": time.time() * 1000, "userId": self.broadcaster.ID}
_url = USER_INFO_API.format_map(_formatData).format_map(_formatData)
@ -304,6 +306,7 @@ class XiGuaLiveApi:
def _getRoomInfo(self, force=False):
if self.roomID == 0:
self.isLive = False
return False
if not force or (self._updRoomAt + timedelta(minutes=2) > datetime.now()):
return self.isLive