feat:新增订阅相关事件
This commit is contained in:
parent
5ee41b87a2
commit
536bd9268a
@ -12,7 +12,7 @@ from app.chain.search import SearchChain
|
|||||||
from app.chain.torrents import TorrentsChain
|
from app.chain.torrents import TorrentsChain
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.context import TorrentInfo, Context, MediaInfo
|
from app.core.context import TorrentInfo, Context, MediaInfo
|
||||||
from app.core.event import eventmanager, Event
|
from app.core.event import eventmanager, Event, EventManager
|
||||||
from app.core.meta import MetaBase
|
from app.core.meta import MetaBase
|
||||||
from app.core.metainfo import MetaInfo
|
from app.core.metainfo import MetaInfo
|
||||||
from app.db.models.subscribe import Subscribe
|
from app.db.models.subscribe import Subscribe
|
||||||
@ -153,6 +153,12 @@ class SubscribeChain(ChainBase):
|
|||||||
title=f"{mediainfo.title_year} {metainfo.season} 已添加订阅",
|
title=f"{mediainfo.title_year} {metainfo.season} 已添加订阅",
|
||||||
text=text,
|
text=text,
|
||||||
image=mediainfo.get_message_image()))
|
image=mediainfo.get_message_image()))
|
||||||
|
# 发送事件
|
||||||
|
EventManager().send_event(EventType.SubscribeAdded, {
|
||||||
|
"subscribe_id": sid,
|
||||||
|
"username": username,
|
||||||
|
"mediainfo": mediainfo.to_dict(),
|
||||||
|
})
|
||||||
# 返回结果
|
# 返回结果
|
||||||
return sid, ""
|
return sid, ""
|
||||||
|
|
||||||
@ -361,6 +367,11 @@ class SubscribeChain(ChainBase):
|
|||||||
self.post_message(Notification(mtype=NotificationType.Subscribe,
|
self.post_message(Notification(mtype=NotificationType.Subscribe,
|
||||||
title=f'{mediainfo.title_year} {meta.season} 已洗版完成',
|
title=f'{mediainfo.title_year} {meta.season} 已洗版完成',
|
||||||
image=mediainfo.get_message_image()))
|
image=mediainfo.get_message_image()))
|
||||||
|
# 发送事件
|
||||||
|
EventManager().send_event(EventType.SubscribeComplete, {
|
||||||
|
"subscribe_id": subscribe.id,
|
||||||
|
"mediainfo": mediainfo.to_dict(),
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
# 正在洗版,更新资源优先级
|
# 正在洗版,更新资源优先级
|
||||||
logger.info(f'{mediainfo.title_year} 正在洗版,更新资源优先级为 {priority}')
|
logger.info(f'{mediainfo.title_year} 正在洗版,更新资源优先级为 {priority}')
|
||||||
@ -391,6 +402,11 @@ class SubscribeChain(ChainBase):
|
|||||||
self.post_message(Notification(mtype=NotificationType.Subscribe,
|
self.post_message(Notification(mtype=NotificationType.Subscribe,
|
||||||
title=f'{mediainfo.title_year} {meta.season} 已完成订阅',
|
title=f'{mediainfo.title_year} {meta.season} 已完成订阅',
|
||||||
image=mediainfo.get_message_image()))
|
image=mediainfo.get_message_image()))
|
||||||
|
# 发送事件
|
||||||
|
EventManager().send_event(EventType.SubscribeComplete, {
|
||||||
|
"subscribe_id": subscribe.id,
|
||||||
|
"mediainfo": mediainfo.to_dict(),
|
||||||
|
})
|
||||||
elif downloads and meta.type == MediaType.TV:
|
elif downloads and meta.type == MediaType.TV:
|
||||||
# 电视剧更新已下载集数
|
# 电视剧更新已下载集数
|
||||||
self.__update_subscribe_note(subscribe=subscribe, downloads=downloads)
|
self.__update_subscribe_note(subscribe=subscribe, downloads=downloads)
|
||||||
|
@ -14,34 +14,38 @@ class TorrentStatus(Enum):
|
|||||||
|
|
||||||
# 可监听事件
|
# 可监听事件
|
||||||
class EventType(Enum):
|
class EventType(Enum):
|
||||||
# 插件重载
|
# 插件需要重载
|
||||||
PluginReload = "plugin.reload"
|
PluginReload = "plugin.reload"
|
||||||
# 插件动作
|
# 插件动作
|
||||||
PluginAction = "plugin.action"
|
PluginAction = "plugin.action"
|
||||||
# 执行命令
|
# 执行命令
|
||||||
CommandExcute = "command.excute"
|
CommandExcute = "command.excute"
|
||||||
# 站点删除
|
# 站点已删除
|
||||||
SiteDeleted = "site.deleted"
|
SiteDeleted = "site.deleted"
|
||||||
# Webhook消息
|
# 站点已更新
|
||||||
WebhookMessage = "webhook.message"
|
SiteUpdated = "site.updated"
|
||||||
# 转移完成
|
# 转移完成
|
||||||
TransferComplete = "transfer.complete"
|
TransferComplete = "transfer.complete"
|
||||||
# 添加下载
|
# 下载已添加
|
||||||
DownloadAdded = "download.added"
|
DownloadAdded = "download.added"
|
||||||
# 删除历史记录
|
# 删除历史记录
|
||||||
HistoryDeleted = "history.deleted"
|
HistoryDeleted = "history.deleted"
|
||||||
# 删除下载源文件
|
# 删除下载源文件
|
||||||
DownloadFileDeleted = "downloadfile.deleted"
|
DownloadFileDeleted = "downloadfile.deleted"
|
||||||
# 用户外来消息
|
# 收到用户外来消息
|
||||||
UserMessage = "user.message"
|
UserMessage = "user.message"
|
||||||
# 通知消息
|
# 收到Webhook消息
|
||||||
|
WebhookMessage = "webhook.message"
|
||||||
|
# 发送消息通知
|
||||||
NoticeMessage = "notice.message"
|
NoticeMessage = "notice.message"
|
||||||
# 名称识别请求
|
# 名称识别请求
|
||||||
NameRecognize = "name.recognize"
|
NameRecognize = "name.recognize"
|
||||||
# 名称识别结果
|
# 名称识别结果
|
||||||
NameRecognizeResult = "name.recognize.result"
|
NameRecognizeResult = "name.recognize.result"
|
||||||
# 站点发生更新
|
# 订阅已添加
|
||||||
SiteUpdated = "site.updated"
|
SubscribeAdded = "subscribe.added"
|
||||||
|
# 订阅已完成
|
||||||
|
SubscribeComplete = "subscribe.complete"
|
||||||
|
|
||||||
|
|
||||||
# 系统配置Key字典
|
# 系统配置Key字典
|
||||||
|
Loading…
x
Reference in New Issue
Block a user