feat 可配置交互搜索自动下载用户
This commit is contained in:
@ -78,6 +78,7 @@ docker pull jxxghp/moviepilot:latest
|
|||||||
- **COOKIECLOUD_PASSWORD:** CookieCloud端对端加密密码
|
- **COOKIECLOUD_PASSWORD:** CookieCloud端对端加密密码
|
||||||
- **COOKIECLOUD_INTERVAL:** CookieCloud同步间隔(分钟)
|
- **COOKIECLOUD_INTERVAL:** CookieCloud同步间隔(分钟)
|
||||||
- **USER_AGENT:** CookieCloud对应的浏览器UA,可选,设置后可增加连接站点的成功率,同步站点后可以在管理界面中修改
|
- **USER_AGENT:** CookieCloud对应的浏览器UA,可选,设置后可增加连接站点的成功率,同步站点后可以在管理界面中修改
|
||||||
|
- **AUTO_DOWNLOAD_USER:** 交互搜索自动下载用户ID,使用,分割
|
||||||
- **MESSAGER:** 消息通知渠道,支持 `telegram`/`wechat`/`slack`,开启多个渠道时使用`,`分隔。同时还需要配置对应渠道的环境变量,非对应渠道的变量可删除,推荐使用`telegram`
|
- **MESSAGER:** 消息通知渠道,支持 `telegram`/`wechat`/`slack`,开启多个渠道时使用`,`分隔。同时还需要配置对应渠道的环境变量,非对应渠道的变量可删除,推荐使用`telegram`
|
||||||
|
|
||||||
- `wechat`设置项:
|
- `wechat`设置项:
|
||||||
|
@ -130,18 +130,29 @@ class MessageChain(ChainBase):
|
|||||||
return
|
return
|
||||||
# 搜索结果排序
|
# 搜索结果排序
|
||||||
contexts = self.torrenthelper.sort_torrents(contexts)
|
contexts = self.torrenthelper.sort_torrents(contexts)
|
||||||
# 更新缓存
|
# 判断是否设置自动下载
|
||||||
user_cache[userid] = {
|
auto_download_user = settings.AUTO_DOWNLOAD_USER
|
||||||
"type": "Torrent",
|
# 匹配到自动下载用户
|
||||||
"items": contexts
|
if auto_download_user and any(userid == user for user in auto_download_user.split(",")):
|
||||||
}
|
logger.info(f"用户 {userid} 在自动下载用户中,开始自动择优下载")
|
||||||
# 发送种子数据
|
# 自动选择下载
|
||||||
logger.info(f"搜索到 {len(contexts)} 条数据,开始发送选择消息 ...")
|
self.__auto_download(channel=channel,
|
||||||
self.__post_torrents_message(channel=channel,
|
cache_list=contexts,
|
||||||
title=mediainfo.title,
|
userid=userid,
|
||||||
items=contexts[:self._page_size],
|
username=username)
|
||||||
userid=userid,
|
else:
|
||||||
total=len(contexts))
|
# 更新缓存
|
||||||
|
user_cache[userid] = {
|
||||||
|
"type": "Torrent",
|
||||||
|
"items": contexts
|
||||||
|
}
|
||||||
|
# 发送种子数据
|
||||||
|
logger.info(f"搜索到 {len(contexts)} 条数据,开始发送选择消息 ...")
|
||||||
|
self.__post_torrents_message(channel=channel,
|
||||||
|
title=mediainfo.title,
|
||||||
|
items=contexts[:self._page_size],
|
||||||
|
userid=userid,
|
||||||
|
total=len(contexts))
|
||||||
|
|
||||||
elif cache_type == "Subscribe":
|
elif cache_type == "Subscribe":
|
||||||
# 订阅媒体
|
# 订阅媒体
|
||||||
@ -168,36 +179,10 @@ class MessageChain(ChainBase):
|
|||||||
elif cache_type == "Torrent":
|
elif cache_type == "Torrent":
|
||||||
if int(text) == 0:
|
if int(text) == 0:
|
||||||
# 自动选择下载
|
# 自动选择下载
|
||||||
# 查询缺失的媒体信息
|
self.__auto_download(channel=channel,
|
||||||
exist_flag, no_exists = self.downloadchain.get_no_exists_info(meta=_current_meta,
|
cache_list=cache_list,
|
||||||
mediainfo=_current_media)
|
userid=userid,
|
||||||
if exist_flag:
|
username=username)
|
||||||
self.post_message(Notification(
|
|
||||||
channel=channel,
|
|
||||||
title=f"{_current_media.title_year}"
|
|
||||||
f"{_current_meta.sea} 媒体库中已存在",
|
|
||||||
userid=userid))
|
|
||||||
return
|
|
||||||
# 批量下载
|
|
||||||
downloads, lefts = self.downloadchain.batch_download(contexts=cache_list,
|
|
||||||
no_exists=no_exists,
|
|
||||||
userid=userid)
|
|
||||||
if downloads and not lefts:
|
|
||||||
# 全部下载完成
|
|
||||||
logger.info(f'{_current_media.title_year} 下载完成')
|
|
||||||
else:
|
|
||||||
# 未完成下载
|
|
||||||
logger.info(f'{_current_media.title_year} 未下载未完整,添加订阅 ...')
|
|
||||||
# 添加订阅,状态为R
|
|
||||||
self.subscribechain.add(title=_current_media.title,
|
|
||||||
year=_current_media.year,
|
|
||||||
mtype=_current_media.type,
|
|
||||||
tmdbid=_current_media.tmdb_id,
|
|
||||||
season=_current_meta.begin_season,
|
|
||||||
channel=channel,
|
|
||||||
userid=userid,
|
|
||||||
username=username,
|
|
||||||
state="R")
|
|
||||||
else:
|
else:
|
||||||
# 下载种子
|
# 下载种子
|
||||||
context: Context = cache_list[int(text) - 1]
|
context: Context = cache_list[int(text) - 1]
|
||||||
@ -336,6 +321,41 @@ class MessageChain(ChainBase):
|
|||||||
# 保存缓存
|
# 保存缓存
|
||||||
self.save_cache(user_cache, self._cache_file)
|
self.save_cache(user_cache, self._cache_file)
|
||||||
|
|
||||||
|
def __auto_download(self, channel, cache_list, userid, username):
|
||||||
|
"""
|
||||||
|
自动择优下载
|
||||||
|
"""
|
||||||
|
# 查询缺失的媒体信息
|
||||||
|
exist_flag, no_exists = self.downloadchain.get_no_exists_info(meta=_current_meta,
|
||||||
|
mediainfo=_current_media)
|
||||||
|
if exist_flag:
|
||||||
|
self.post_message(Notification(
|
||||||
|
channel=channel,
|
||||||
|
title=f"{_current_media.title_year}"
|
||||||
|
f"{_current_meta.sea} 媒体库中已存在",
|
||||||
|
userid=userid))
|
||||||
|
return
|
||||||
|
# 批量下载
|
||||||
|
downloads, lefts = self.downloadchain.batch_download(contexts=cache_list,
|
||||||
|
no_exists=no_exists,
|
||||||
|
userid=userid)
|
||||||
|
if downloads and not lefts:
|
||||||
|
# 全部下载完成
|
||||||
|
logger.info(f'{_current_media.title_year} 下载完成')
|
||||||
|
else:
|
||||||
|
# 未完成下载
|
||||||
|
logger.info(f'{_current_media.title_year} 未下载未完整,添加订阅 ...')
|
||||||
|
# 添加订阅,状态为R
|
||||||
|
self.subscribechain.add(title=_current_media.title,
|
||||||
|
year=_current_media.year,
|
||||||
|
mtype=_current_media.type,
|
||||||
|
tmdbid=_current_media.tmdb_id,
|
||||||
|
season=_current_meta.begin_season,
|
||||||
|
channel=channel,
|
||||||
|
userid=userid,
|
||||||
|
username=username,
|
||||||
|
state="R")
|
||||||
|
|
||||||
def __post_medias_message(self, channel: MessageChannel,
|
def __post_medias_message(self, channel: MessageChannel,
|
||||||
title: str, items: list, userid: str, total: int):
|
title: str, items: list, userid: str, total: int):
|
||||||
"""
|
"""
|
||||||
|
@ -65,6 +65,8 @@ class Settings(BaseSettings):
|
|||||||
INDEXER: str = "builtin"
|
INDEXER: str = "builtin"
|
||||||
# 用户认证站点 hhclub/audiences/hddolby/zmpt/freefarm/hdfans/wintersakura/leaves/1ptba/icc2022/iyuu
|
# 用户认证站点 hhclub/audiences/hddolby/zmpt/freefarm/hdfans/wintersakura/leaves/1ptba/icc2022/iyuu
|
||||||
AUTH_SITE: str = ""
|
AUTH_SITE: str = ""
|
||||||
|
# 交互搜索自动下载用户ID,使用,分割
|
||||||
|
AUTO_DOWNLOAD_USER: str = None
|
||||||
# 消息通知渠道 telegram/wechat/slack
|
# 消息通知渠道 telegram/wechat/slack
|
||||||
MESSAGER: str = "telegram"
|
MESSAGER: str = "telegram"
|
||||||
# WeChat企业ID
|
# WeChat企业ID
|
||||||
|
Reference in New Issue
Block a user