mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
refactor: 添加订阅协程处理
This commit is contained in:
@@ -657,6 +657,17 @@ class MessageQueueManager(metaclass=SingletonClass):
|
||||
})
|
||||
logger.info(f"消息已加入队列,当前队列长度:{self.queue.qsize()}")
|
||||
|
||||
async def async_send_message(self, *args, **kwargs) -> None:
|
||||
"""
|
||||
异步发送消息(直接加入队列)
|
||||
"""
|
||||
kwargs.pop("immediately", False)
|
||||
self.queue.put({
|
||||
"args": args,
|
||||
"kwargs": kwargs
|
||||
})
|
||||
logger.info(f"消息已加入队列,当前队列长度:{self.queue.qsize()}")
|
||||
|
||||
def _send(self, *args, **kwargs) -> None:
|
||||
"""
|
||||
实际发送消息(可通过回调函数自定义)
|
||||
|
||||
@@ -173,6 +173,20 @@ class SubscribeHelper(metaclass=WeakSingleton):
|
||||
return True
|
||||
return False
|
||||
|
||||
async def async_sub_reg(self, sub: dict) -> bool:
|
||||
"""
|
||||
异步新增订阅统计
|
||||
"""
|
||||
enabled, _ = self._check_subscribe_share_enabled()
|
||||
if not enabled:
|
||||
return False
|
||||
res = await AsyncRequestUtils(proxies=settings.PROXY, timeout=5, headers={
|
||||
"Content-Type": "application/json"
|
||||
}).post_res(self._sub_reg, json=sub)
|
||||
if res and res.status_code == 200:
|
||||
return True
|
||||
return False
|
||||
|
||||
def sub_done(self, sub: dict) -> bool:
|
||||
"""
|
||||
完成订阅统计
|
||||
|
||||
Reference in New Issue
Block a user