Merge pull request #42 from yubanmeiqin9048/main

This commit is contained in:
jxxghp 2023-08-08 13:24:57 +08:00 committed by GitHub
commit 3f8c5fbf48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View File

@ -549,6 +549,7 @@ class MediaInfo:
dicts["type"] = self.type.value if self.type else None
dicts["detail_link"] = self.detail_link
dicts["title_year"] = self.title_year
dicts["tmdb_info"]["media_type"] = self.type.value if self.type else None
return dicts
def clear(self):

View File

@ -135,10 +135,21 @@ class WebHook(_PluginBase):
"""
if not self._webhook_url:
return
def __to_dict(event):
result = {}
for key, value in event.items():
if hasattr(value, 'to_dict'):
result[key] = value.to_dict()
else:
result[key] = str(value)
return result
event_info = {
"type": event.event_type,
"data": str(event.event_data)
"data": __to_dict(event.event_data)
}
if self._method == 'POST':
ret = RequestUtils(content_type="application/json").post_res(self._webhook_url, json=event_info)
else:

View File

@ -4,6 +4,7 @@ from typing import Optional
from pydantic import BaseModel
class TransferTorrent(BaseModel):
"""
待转移任务信息
@ -51,3 +52,12 @@ class TransferInfo(BaseModel):
fail_list: Optional[list] = []
# 错误信息
message: Optional[str] = None
def to_dict(self):
"""
返回字典
"""
dicts = vars(self).copy() # 创建一个字典的副本以避免修改原始数据
dicts["path"] = str(self.path) if self.path else None
dicts["target_path"] = str(self.target_path) if self.target_path else None
return dicts