@@ -72,23 +72,26 @@ async def autocheck(self):
72
72
logging .error ('Streamer.autocheck.BaseException' , exc_info = True )
73
73
await self .sendMessage (f'[{ self .name } ]autocheck发生错误,请查看日志' )
74
74
75
- async def stopRbcCheck (self , state ):
75
+ async def stopRbcCheck (self , state ): # 用于检查是否真的是直播结束
76
76
if (self .state ['status' ] != 'OK' ):
77
77
self .state = state
78
78
await asyncio .sleep (15 )
79
79
return
80
80
islive = await youtube_util .checkIsLive (self .state ["videoid" ])
81
81
logging .warning (f'checkIsLive.status:{ islive } ' )
82
82
if islive ['status' ] == 'OK' :
83
- logging .warning (f'youtube抽风了\n [{ self .name } ]直播状态:{ state } 原状态:{ self .state } ' )
83
+ logging .warning (
84
+ f'youtube抽风了\n [{ self .name } ]直播状态:{ state } 原状态:{ self .state } ' )
84
85
await asyncio .sleep (15 )
85
86
return False
86
87
else :
87
88
if state ['status' ] == 'OK' :
88
- logging .warning (f'不是youtube抽风,切换到新的<直播>页面\n [{ self .name } ]直播状态:{ state } 原状态:{ self .state } ' )
89
+ logging .warning (
90
+ f'不是youtube抽风,切换到新的<直播>页面\n [{ self .name } ]直播状态:{ state } 原状态:{ self .state } ' )
89
91
self .startRebroadcast (state ['videoid' ])
90
92
else :
91
- logging .warning (f'不是youtube抽风,切换到新的<待机>页面\n [{ self .name } ]直播状态:{ state } 原状态:{ self .state } ' )
93
+ logging .warning (
94
+ f'不是youtube抽风,切换到新的<待机>页面\n [{ self .name } ]直播状态:{ state } 原状态:{ self .state } ' )
92
95
await self .stopRebroadcast ()
93
96
self .state = state
94
97
await asyncio .sleep (15 )
@@ -105,7 +108,7 @@ async def startRebroadcast(self, videoid):
105
108
self .queue .put ((self .name , videoid ))
106
109
self .rbcThread = Rebroadcast .RebroadcastThread (self .queue )
107
110
self .rbcThread .start ()
108
- await self .sendMessage (f'{ self .name } { self .getState (state = videoid ,type = "detail" )} ' )
111
+ await self .sendMessage (f'{ self .name } { self .getState (state = { " videoid" : videoid , "status" : "OK" } ,type = "detail" )} ' )
109
112
110
113
async def stopRebroadcast (self ):
111
114
logging .info (f'改变转播状态:[{ self .name } ]stop' )
@@ -119,15 +122,15 @@ def getState(self, state='', type='simple'):
119
122
if state == '' :
120
123
state = self .state
121
124
if type == 'simple' :
122
- if state is None :
123
- return '未直播 '
125
+ if state [ 'status' ] == 'OK' :
126
+ return f'正在直播中: { state [ "videoid" ] } '
124
127
else :
125
- return f'正在直播中:{ state } '
126
- elif type == 'detail' :
127
- if state is None :
128
128
return '未直播'
129
+ elif type == 'detail' :
130
+ if state ['status' ] == 'OK' :
131
+ return f'正在直播中:https://www.youtube.com/watch?v={ state ["videoid" ]} \n 转播链接:{ APIKey .rebroadcast_prefix } { self .name } '
129
132
else :
130
- return f'正在直播中:https://www.youtube.com/watch?v= { state } \n 转播链接: { APIKey . rebroadcast_prefix } { self . name } '
133
+ return '未直播 '
131
134
132
135
async def sendMessage (self , msg ):
133
136
if self .discord is None :
0 commit comments