diff --git a/Common.py b/Common.py index 4b04efe..113b004 100644 --- a/Common.py +++ b/Common.py @@ -153,7 +153,6 @@ dt_format = "%Y/%m/%d %H:%M:%S" reloadConfig() broadcaster = "" streamUrl = "" -updateTime = "" forceNotDownload = False forceNotBroadcasting = False @@ -307,11 +306,10 @@ class downloader(XiGuaLiveApi): playlist = None def updRoomInfo(self, force=False): - global broadcaster, updateTime + global broadcaster _prev_status = self.isLive doClean() _result = super(downloader, self).updRoomInfo(force) - updateTime = datetime.now().strftime(dt_format) if _prev_status != self.isLive: resetDelay() if _result: @@ -397,7 +395,7 @@ def collectInfomation(): "broadcaster": broadcaster.__str__(), "isBroadcasting": api.isLive, "streamUrl": streamUrl, - "updateTime": updateTime, + "updateTime": api.updateAt.strftime(dt_format), "delayTime": delay.strftime(dt_format) }, "config": { diff --git a/api.py b/api.py index 3c36f8c..0e6fbc3 100644 --- a/api.py +++ b/api.py @@ -188,6 +188,7 @@ class XiGuaLiveApi: if "user_info" not in d and d["user_info"] is None: self.apiChangedError("Api发生改变,请及时联系我", d) return False + self._updRoomAt = datetime.now() self.broadcaster = User(d) if not self._checkUsernameIsMatched(): self.isLive = False @@ -230,3 +231,7 @@ class XiGuaLiveApi: return self._updateUserInfo() else: return self._getRoomInfo(force) + + @property + def updateAt(self): + return self._updRoomAt diff --git a/bilibili.py b/bilibili.py index 8ed3553..4d34055 100644 --- a/bilibili.py +++ b/bilibili.py @@ -142,7 +142,7 @@ class Bilibili: ) json = r.json() - if json['code'] is not 0: + if json['code'] != 0: return r.text ls = []