add webhook schemas
This commit is contained in:
@ -4,7 +4,7 @@ from typing import List, Union, Optional, Dict, Generator
|
||||
|
||||
from app.core.config import settings
|
||||
from app.log import logger
|
||||
from app.schemas import MediaType
|
||||
from app.schemas import MediaType, WebhookEventInfo
|
||||
from app.utils.http import RequestUtils
|
||||
from app.utils.singleton import Singleton
|
||||
from app.utils.string import StringUtils
|
||||
@ -365,21 +365,22 @@ class Jellyfin(metaclass=Singleton):
|
||||
logger.error(f"连接Library/Refresh出错:" + str(e))
|
||||
return False
|
||||
|
||||
def get_webhook_message(self, message: dict) -> dict:
|
||||
def get_webhook_message(self, message: dict) -> WebhookEventInfo:
|
||||
"""
|
||||
解析Jellyfin报文
|
||||
"""
|
||||
eventItem = {'event': message.get('NotificationType', ''),
|
||||
'item_name': message.get('Name'),
|
||||
'user_name': message.get('NotificationUsername'),
|
||||
"channel": "jellyfin"
|
||||
}
|
||||
eventItem = WebhookEventInfo(
|
||||
event=message.get('NotificationType', ''),
|
||||
item_name=message.get('Name'),
|
||||
user_name=message.get('NotificationUsername'),
|
||||
channel="jellyfin"
|
||||
)
|
||||
|
||||
# 获取消息图片
|
||||
if eventItem.get("item_id"):
|
||||
if eventItem.item_id:
|
||||
# 根据返回的item_id去调用媒体服务器获取
|
||||
eventItem['image_url'] = self.get_remote_image_by_id(item_id=eventItem.get('item_id'),
|
||||
image_type="Backdrop")
|
||||
eventItem.image_url = self.get_remote_image_by_id(item_id=eventItem.item_id,
|
||||
image_type="Backdrop")
|
||||
|
||||
return eventItem
|
||||
|
||||
|
Reference in New Issue
Block a user