Merge branch 'main' into main

This commit is contained in:
Summer⛱ 2023-10-28 18:30:01 +08:00 committed by GitHub
commit 6d3e33a05d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 12 deletions

View File

@ -60,7 +60,6 @@ MoviePilot需要配套下载器和媒体服务器配合使用。
- **PUID**:运行程序用户的`uid`,默认`0`(仅支持环境变量配置) - **PUID**:运行程序用户的`uid`,默认`0`(仅支持环境变量配置)
- **PGID**:运行程序用户的`gid`,默认`0`(仅支持环境变量配置) - **PGID**:运行程序用户的`gid`,默认`0`(仅支持环境变量配置)
- **UMASK**:掩码权限,默认`000`,可以考虑设置为`022`(仅支持环境变量配置) - **UMASK**:掩码权限,默认`000`,可以考虑设置为`022`(仅支持环境变量配置)
- **WALLPAPER** 登录首页电影海报,`tmdb`/`bing`,默认`tmdb`
- **PROXY_HOST** 网络代理访问themoviedb或者重启更新需要使用代理访问格式为`http(s)://ip:port``socks5://user:pass@host:port`(仅支持环境变量配置) - **PROXY_HOST** 网络代理访问themoviedb或者重启更新需要使用代理访问格式为`http(s)://ip:port``socks5://user:pass@host:port`(仅支持环境变量配置)
- **MOVIEPILOT_AUTO_UPDATE**:重启更新,`true`/`false`,默认`true` **注意:如果出现网络问题可以配置`PROXY_HOST`**(仅支持环境变量配置) - **MOVIEPILOT_AUTO_UPDATE**:重启更新,`true`/`false`,默认`true` **注意:如果出现网络问题可以配置`PROXY_HOST`**(仅支持环境变量配置)
- **MOVIEPILOT_AUTO_UPDATE_DEV**:重启时更新到未发布的开发版本代码,`true`/`false`,默认`false`(仅支持环境变量配置) - **MOVIEPILOT_AUTO_UPDATE_DEV**:重启时更新到未发布的开发版本代码,`true`/`false`,默认`false`(仅支持环境变量配置)
@ -70,6 +69,7 @@ MoviePilot需要配套下载器和媒体服务器配合使用。
- **❗API_TOKEN** API密钥默认`moviepilot`在媒体服务器Webhook、微信回调等地址配置中需要加上`?token=`该值,建议修改为复杂字符串 - **❗API_TOKEN** API密钥默认`moviepilot`在媒体服务器Webhook、微信回调等地址配置中需要加上`?token=`该值,建议修改为复杂字符串
- **TMDB_API_DOMAIN** TMDB API地址默认`api.themoviedb.org`,也可配置为`api.tmdb.org`或其它中转代理服务地址,能连通即可 - **TMDB_API_DOMAIN** TMDB API地址默认`api.themoviedb.org`,也可配置为`api.tmdb.org`或其它中转代理服务地址,能连通即可
- **TMDB_IMAGE_DOMAIN** TMDB图片地址默认`image.tmdb.org`可配置为其它中转代理以加速TMDB图片显示`static-mdb.v.geilijiasu.com` - **TMDB_IMAGE_DOMAIN** TMDB图片地址默认`image.tmdb.org`可配置为其它中转代理以加速TMDB图片显示`static-mdb.v.geilijiasu.com`
- **WALLPAPER** 登录首页电影海报,`tmdb`/`bing`,默认`tmdb`
--- ---
- **SCRAP_METADATA** 刮削入库的媒体文件,`true`/`false`,默认`true` - **SCRAP_METADATA** 刮削入库的媒体文件,`true`/`false`,默认`true`
- **SCRAP_SOURCE** 刮削元数据及图片使用的数据源,`themoviedb`/`douban`,默认`themoviedb` - **SCRAP_SOURCE** 刮削元数据及图片使用的数据源,`themoviedb`/`douban`,默认`themoviedb`
@ -144,6 +144,7 @@ MoviePilot需要配套下载器和媒体服务器配合使用。
- **QB_PASSWORD** qbittorrent密码 - **QB_PASSWORD** qbittorrent密码
- **QB_CATEGORY** qbittorrent分类自动管理`true`/`false`,默认`false`,开启后会将下载二级分类传递到下载器,由下载器管理下载目录,需要同步开启`DOWNLOAD_CATEGORY` - **QB_CATEGORY** qbittorrent分类自动管理`true`/`false`,默认`false`,开启后会将下载二级分类传递到下载器,由下载器管理下载目录,需要同步开启`DOWNLOAD_CATEGORY`
- **QB_SEQUENTIAL** qbittorrent按顺序下载`true`/`false`,默认`true` - **QB_SEQUENTIAL** qbittorrent按顺序下载`true`/`false`,默认`true`
- **QB_FORCE_RESUME** qbittorrent忽略队列限制强制继续`true`/`false`,默认 `false`
- `transmission`设置项: - `transmission`设置项:

View File

@ -75,10 +75,14 @@ def delete_transfer_history(history_in: schemas.TransferHistory,
return schemas.Response(success=False, msg="记录不存在") return schemas.Response(success=False, msg="记录不存在")
# 册除媒体库文件 # 册除媒体库文件
if deletedest and history.dest: if deletedest and history.dest:
TransferChain().delete_files(Path(history.dest)) state, msg = TransferChain().delete_files(Path(history.dest))
if not state:
return schemas.Response(success=False, msg=msg)
# 删除源文件 # 删除源文件
if deletesrc and history.src: if deletesrc and history.src:
TransferChain().delete_files(Path(history.src)) state, msg = TransferChain().delete_files(Path(history.src))
if not state:
return schemas.Response(success=False, msg=msg)
# 发送事件 # 发送事件
eventmanager.send_event( eventmanager.send_event(
EventType.DownloadFileDeleted, EventType.DownloadFileDeleted,

View File

@ -617,14 +617,15 @@ class TransferChain(ChainBase):
title=msg_title, text=msg_str, image=mediainfo.get_message_image())) title=msg_title, text=msg_str, image=mediainfo.get_message_image()))
@staticmethod @staticmethod
def delete_files(path: Path): def delete_files(path: Path) -> Tuple[bool, str]:
""" """
删除转移后的文件以及空目录 删除转移后的文件以及空目录
:param path: 文件路径 :param path: 文件路径
:return: 成功标识错误信息
""" """
logger.info(f"开始删除文件以及空目录:{path} ...") logger.info(f"开始删除文件以及空目录:{path} ...")
if not path.exists(): if not path.exists():
return return True, f"文件或目录不存在:{path}"
if path.is_file(): if path.is_file():
# 删除文件、nfo、jpg等同名文件 # 删除文件、nfo、jpg等同名文件
pattern = path.stem.replace('[', '?').replace(']', '?') pattern = path.stem.replace('[', '?').replace(']', '?')
@ -636,7 +637,7 @@ class TransferChain(ChainBase):
elif str(path.parent) == str(path.root): elif str(path.parent) == str(path.root):
# 根目录,不删除 # 根目录,不删除
logger.warn(f"根目录 {path} 不能删除!") logger.warn(f"根目录 {path} 不能删除!")
return return False, f"根目录 {path} 不能删除!"
else: else:
# 非根目录,才删除目录 # 非根目录,才删除目录
shutil.rmtree(path) shutil.rmtree(path)
@ -662,5 +663,10 @@ class TransferChain(ChainBase):
# 父目录非根目录,才删除父目录 # 父目录非根目录,才删除父目录
if not SystemUtils.exits_files(parent_path, settings.RMT_MEDIAEXT): if not SystemUtils.exits_files(parent_path, settings.RMT_MEDIAEXT):
# 当前路径下没有媒体文件则删除 # 当前路径下没有媒体文件则删除
shutil.rmtree(parent_path) try:
shutil.rmtree(parent_path)
except Exception as e:
logger.error(f"删除目录 {parent_path} 失败:{str(e)}")
return False, f"删除目录 {parent_path} 失败:{str(e)}"
logger.warn(f"目录 {parent_path} 已删除") logger.warn(f"目录 {parent_path} 已删除")
return True, ""

View File

@ -131,6 +131,8 @@ class Settings(BaseSettings):
QB_CATEGORY: bool = False QB_CATEGORY: bool = False
# Qbittorrent按顺序下载 # Qbittorrent按顺序下载
QB_SEQUENTIAL: bool = True QB_SEQUENTIAL: bool = True
# Qbittorrent忽略队列限制强制继续
QB_FORCE_RESUME: bool = False
# Transmission地址IP:PORT # Transmission地址IP:PORT
TR_HOST: str = None TR_HOST: str = None
# Transmission用户名 # Transmission用户名

View File

@ -101,9 +101,15 @@ class QbittorrentModule(_ModuleBase):
# 选择文件 # 选择文件
self.qbittorrent.set_files(torrent_hash=torrent_hash, file_ids=file_ids, priority=0) self.qbittorrent.set_files(torrent_hash=torrent_hash, file_ids=file_ids, priority=0)
# 开始任务 # 开始任务
self.qbittorrent.start_torrents(torrent_hash) if settings.QB_FORCE_RESUME:
# 强制继续
self.qbittorrent.torrents_set_force_start(torrent_hash)
else:
self.qbittorrent.start_torrents(torrent_hash)
return torrent_hash, f"添加下载成功,已选择集数:{sucess_epidised}" return torrent_hash, f"添加下载成功,已选择集数:{sucess_epidised}"
else: else:
if settings.QB_FORCE_RESUME:
self.qbittorrent.torrents_set_force_start(torrent_hash)
return torrent_hash, "添加下载成功" return torrent_hash, "添加下载成功"
def list_torrents(self, status: TorrentStatus = None, def list_torrents(self, status: TorrentStatus = None,

View File

@ -11,11 +11,9 @@ from lxml import etree
from ruamel.yaml import CommentedMap from ruamel.yaml import CommentedMap
from app.core.config import settings from app.core.config import settings
from app.core.event import eventmanager
from app.db.site_oper import SiteOper from app.db.site_oper import SiteOper
from app.helper.sites import SitesHelper from app.helper.sites import SitesHelper
from app.core.event import eventmanager
from app.db.models.site import Site
from app.helper.torrent import TorrentHelper from app.helper.torrent import TorrentHelper
from app.log import logger from app.log import logger
from app.modules.qbittorrent import Qbittorrent from app.modules.qbittorrent import Qbittorrent

View File

@ -38,7 +38,7 @@ class DownloadHistory(BaseModel):
torrent_site: Optional[str] = None torrent_site: Optional[str] = None
# 下载用户 # 下载用户
userid: Optional[str] = None userid: Optional[str] = None
# 下载用户名插件名 # 下载用户名
username: Optional[str] = None username: Optional[str] = None
# 下载渠道 # 下载渠道
channel: Optional[str] = None channel: Optional[str] = None

View File

@ -143,6 +143,8 @@ QB_PASSWORD=
QB_CATEGORY=false QB_CATEGORY=false
# Qbittorrent按顺序下载 # Qbittorrent按顺序下载
QB_SEQUENTIAL=true QB_SEQUENTIAL=true
# Qbittorrent忽略队列限制强制继续
QB_FORCE_RESUME=false
# Transmission地址IP:PORT # Transmission地址IP:PORT
TR_HOST= TR_HOST=
# Transmission用户名 # Transmission用户名