不存在时的判断
This commit is contained in:
parent
6a2288a45d
commit
bb5fa72f50
3
api.py
3
api.py
@ -254,6 +254,7 @@ class XiGuaLiveApi:
|
|||||||
print("搜索接口请求失败")
|
print("搜索接口请求失败")
|
||||||
return False
|
return False
|
||||||
self.broadcaster = None
|
self.broadcaster = None
|
||||||
|
self.isValidUser = False
|
||||||
if "data" in d and d["data"] is not None:
|
if "data" in d and d["data"] is not None:
|
||||||
for i in d["data"]:
|
for i in d["data"]:
|
||||||
if self.broadcaster is not None:
|
if self.broadcaster is not None:
|
||||||
@ -276,6 +277,7 @@ class XiGuaLiveApi:
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if self.broadcaster is None:
|
if self.broadcaster is None:
|
||||||
|
self.isValidUser = False
|
||||||
return False
|
return False
|
||||||
_formatData = {"COMMON": COMMON_GET_PARAM, "TIMESTAMP": time.time() * 1000, "userId": self.broadcaster.ID}
|
_formatData = {"COMMON": COMMON_GET_PARAM, "TIMESTAMP": time.time() * 1000, "userId": self.broadcaster.ID}
|
||||||
_url = USER_INFO_API.format_map(_formatData).format_map(_formatData)
|
_url = USER_INFO_API.format_map(_formatData).format_map(_formatData)
|
||||||
@ -304,6 +306,7 @@ class XiGuaLiveApi:
|
|||||||
|
|
||||||
def _getRoomInfo(self, force=False):
|
def _getRoomInfo(self, force=False):
|
||||||
if self.roomID == 0:
|
if self.roomID == 0:
|
||||||
|
self.isLive = False
|
||||||
return False
|
return False
|
||||||
if not force or (self._updRoomAt + timedelta(minutes=2) > datetime.now()):
|
if not force or (self._updRoomAt + timedelta(minutes=2) > datetime.now()):
|
||||||
return self.isLive
|
return self.isLive
|
||||||
|
Reference in New Issue
Block a user