Merge branch 'jxxghp:main' into main

This commit is contained in:
s0mE 2024-03-16 19:24:25 +08:00 committed by GitHub
commit cc94c6c367
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 25 additions and 15 deletions

View File

@ -21,7 +21,11 @@
### 2. **安装CookieCloud服务端可选** ### 2. **安装CookieCloud服务端可选**
MoviePilot内置了公共CookieCloud服务器如果需要自建服务可参考 [CookieCloud](https://github.com/easychen/CookieCloud) 项目进行搭建docker镜像请点击 [这里](https://hub.docker.com/r/easychen/cookiecloud)。 通过CookieCloud可以快速同步浏览器中保存的站点数据到MoviePilot支持以下服务方式
- 使用公共CookieCloud服务器默认服务器地址为https://movie-pilot.org/cookiecloud
- 使用内建的本地Cookie服务设置`COOKIECLOUD_ENABLE_LOCAL``true`时启用,服务地址为:`http://localhost:${NGINX_PORT}/cookiecloud/`, Cookie数据加密保存在配置文件目录下的`cookies`文件中
- 自建服务CookieCloud服务器参考 [CookieCloud](https://github.com/easychen/CookieCloud) 项目进行搭建docker镜像请点击 [这里](https://hub.docker.com/r/easychen/cookiecloud)
**声明:** 本项目不会收集用户敏感数据Cookie同步也是基于CookieCloud项目实现非本项目提供的能力。技术角度上CookieCloud采用端到端加密在个人不泄露`用户KEY``端对端加密密码`的情况下第三方无法窃取任何用户信息(包括服务器持有者)。如果你不放心,可以不使用公共服务或者不使用本项目,但如果使用后发生了任何信息泄露与本项目无关! **声明:** 本项目不会收集用户敏感数据Cookie同步也是基于CookieCloud项目实现非本项目提供的能力。技术角度上CookieCloud采用端到端加密在个人不泄露`用户KEY``端对端加密密码`的情况下第三方无法窃取任何用户信息(包括服务器持有者)。如果你不放心,可以不使用公共服务或者不使用本项目,但如果使用后发生了任何信息泄露与本项目无关!
@ -224,7 +228,7 @@ location / {
server { server {
listen 443 ssl; listen 443 ssl;
http2 on; http2 on;
... # ...
} }
``` ```
- 新建的企业微信应用需要固定公网IP的代理才能收到消息代理添加以下代码 - 新建的企业微信应用需要固定公网IP的代理才能收到消息代理添加以下代码

View File

@ -49,7 +49,7 @@ def web_message(text: str, current_user: User = Depends(get_current_active_super
""" """
MessageChain().handle_message( MessageChain().handle_message(
channel=MessageChannel.Web, channel=MessageChannel.Web,
userid=current_user.id, userid=current_user.name,
username=current_user.name, username=current_user.name,
text=text text=text
) )

View File

@ -14,6 +14,8 @@ from app.utils.common import get_decrypted_cookie_data
class GzipRequest(Request): class GzipRequest(Request):
_body: bytes = b""
async def body(self) -> bytes: async def body(self) -> bytes:
if not hasattr(self, "_body"): if not hasattr(self, "_body"):
body = await super().body() body = await super().body()
@ -66,10 +68,9 @@ async def update_cookie(req: schemas.CookieData):
content = json.dumps({"encrypted": req.encrypted}) content = json.dumps({"encrypted": req.encrypted})
with open(file_path, encoding="utf-8", mode="w") as file: with open(file_path, encoding="utf-8", mode="w") as file:
file.write(content) file.write(content)
read_content = None
with open(file_path, encoding="utf-8", mode="r") as file: with open(file_path, encoding="utf-8", mode="r") as file:
read_content = file.read() read_content = file.read()
if (read_content == content): if read_content == content:
return {"action": "done"} return {"action": "done"}
else: else:
return {"action": "error"} return {"action": "error"}

View File

@ -437,12 +437,13 @@ class ChainBase(metaclass=ABCMeta):
:param medias: 媒体列表 :param medias: 媒体列表
:return: 成功或失败 :return: 成功或失败
""" """
self.messagehelper.put(message, role="user") note_list = [media.to_dict() for media in medias]
self.messagehelper.put(message, role="user", note=note_list)
self.messageoper.add(channel=message.channel, mtype=message.mtype, self.messageoper.add(channel=message.channel, mtype=message.mtype,
title=message.title, text=message.text, title=message.title, text=message.text,
image=message.image, link=message.link, image=message.image, link=message.link,
userid=message.userid, action=1, userid=message.userid, action=1,
note=[media.to_dict() for media in medias]) note=note_list)
return self.run_module("post_medias_message", message=message, medias=medias) return self.run_module("post_medias_message", message=message, medias=medias)
def post_torrents_message(self, message: Notification, torrents: List[Context]) -> Optional[bool]: def post_torrents_message(self, message: Notification, torrents: List[Context]) -> Optional[bool]:
@ -452,12 +453,13 @@ class ChainBase(metaclass=ABCMeta):
:param torrents: 种子列表 :param torrents: 种子列表
:return: 成功或失败 :return: 成功或失败
""" """
self.messagehelper.put(message, role="user") note_list = [torrent.torrent_info.to_dict() for torrent in torrents]
self.messagehelper.put(message, role="user", note=note_list)
self.messageoper.add(channel=message.channel, mtype=message.mtype, self.messageoper.add(channel=message.channel, mtype=message.mtype,
title=message.title, text=message.text, title=message.title, text=message.text,
image=message.image, link=message.link, image=message.image, link=message.link,
userid=message.userid, action=1, userid=message.userid, action=1,
note=[torrent.to_dict() for torrent in torrents]) note=note_list)
return self.run_module("post_torrents_message", message=message, torrents=torrents) return self.run_module("post_torrents_message", message=message, torrents=torrents)
def scrape_metadata(self, path: Path, mediainfo: MediaInfo, transfer_type: str, def scrape_metadata(self, path: Path, mediainfo: MediaInfo, transfer_type: str,

View File

@ -615,6 +615,7 @@ class MediaInfo:
""" """
返回字典 返回字典
""" """
self.clear()
dicts = asdict(self) dicts = asdict(self)
dicts["type"] = self.type.value if self.type else None dicts["type"] = self.type.value if self.type else None
dicts["detail_link"] = self.detail_link dicts["detail_link"] = self.detail_link

View File

@ -50,7 +50,7 @@ class MessageOper(DbOper):
"userid": userid, "userid": userid,
"action": action, "action": action,
"reg_time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), "reg_time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
"note": json.dumps(note or {}) "note": json.dumps(note) if note else ''
}) })
Message(**kwargs).create(self._db) Message(**kwargs).create(self._db)

View File

@ -14,11 +14,12 @@ class MessageHelper(metaclass=Singleton):
self.sys_queue = queue.Queue() self.sys_queue = queue.Queue()
self.user_queue = queue.Queue() self.user_queue = queue.Queue()
def put(self, message: Any, role: str = "sys"): def put(self, message: Any, role: str = "sys", note: dict = None):
""" """
存消息 存消息
:param message: 消息 :param message: 消息
:param role: 消息通道 sys/user :param role: 消息通道 sys/user
:param note: 附件json
""" """
if role == "sys": if role == "sys":
self.sys_queue.put(message) self.sys_queue.put(message)
@ -28,6 +29,7 @@ class MessageHelper(metaclass=Singleton):
elif hasattr(message, "to_dict"): elif hasattr(message, "to_dict"):
content = message.to_dict() content = message.to_dict()
content['date'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) content['date'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
content['note'] = json.dumps(note) if note else None
self.user_queue.put(json.dumps(content)) self.user_queue.put(json.dumps(content))
def get(self, role: str = "sys") -> Optional[str]: def get(self, role: str = "sys") -> Optional[str]:

View File

@ -55,7 +55,7 @@ class ResourceHelper(metaclass=Singleton):
target = resource.get("target") target = resource.get("target")
version = resource.get("version") version = resource.get("version")
# 判断平台 # 判断平台
if platform and platform != SystemUtils.platform: if platform and platform != SystemUtils.platform():
continue continue
# 判断本地是否存在 # 判断本地是否存在
local_path = self._base_dir / target / rname local_path = self._base_dir / target / rname

View File

@ -71,8 +71,8 @@ class SystemUtils:
""" """
return True if platform.machine() == 'aarch64' else False return True if platform.machine() == 'aarch64' else False
@property @staticmethod
def platform(self) -> str: def platform() -> str:
""" """
获取系统平台 获取系统平台
""" """