mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-05-11 09:59:51 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
404a7b8337 | ||
|
|
71ce3a2920 | ||
|
|
3a27656769 | ||
|
|
27b1e0ffd5 | ||
|
|
1401ea74dd | ||
|
|
cb93a63970 |
@@ -85,15 +85,18 @@ def delete_transfer_history(history_in: schemas.TransferHistory,
|
|||||||
|
|
||||||
@router.post("/transfer", summary="历史记录重新转移", response_model=schemas.Response)
|
@router.post("/transfer", summary="历史记录重新转移", response_model=schemas.Response)
|
||||||
def redo_transfer_history(history_in: schemas.TransferHistory,
|
def redo_transfer_history(history_in: schemas.TransferHistory,
|
||||||
mtype: str,
|
mtype: str = None,
|
||||||
new_tmdbid: int,
|
new_tmdbid: int = None,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
"""
|
"""
|
||||||
历史记录重新转移
|
历史记录重新转移,不输入 mtype 和 new_tmdbid 时,自动使用文件名重新识别
|
||||||
"""
|
"""
|
||||||
state, errmsg = TransferChain(db).re_transfer(logid=history_in.id,
|
if mtype and new_tmdbid:
|
||||||
mtype=MediaType(mtype), tmdbid=new_tmdbid)
|
state, errmsg = TransferChain(db).re_transfer(logid=history_in.id,
|
||||||
|
mtype=MediaType(mtype), tmdbid=new_tmdbid)
|
||||||
|
else:
|
||||||
|
state, errmsg = TransferChain(db).re_transfer(logid=history_in.id)
|
||||||
if state:
|
if state:
|
||||||
return schemas.Response(success=True)
|
return schemas.Response(success=True)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ def read_sites(db: Session = Depends(get_db),
|
|||||||
|
|
||||||
|
|
||||||
@router.post("/", summary="新增站点", response_model=schemas.Response)
|
@router.post("/", summary="新增站点", response_model=schemas.Response)
|
||||||
def update_site(
|
def add_site(
|
||||||
*,
|
*,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
site_in: schemas.Site,
|
site_in: schemas.Site,
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ def update_subscribe(
|
|||||||
subscribe = Subscribe.get(db, subscribe_in.id)
|
subscribe = Subscribe.get(db, subscribe_in.id)
|
||||||
if not subscribe:
|
if not subscribe:
|
||||||
return schemas.Response(success=False, message="订阅不存在")
|
return schemas.Response(success=False, message="订阅不存在")
|
||||||
if subscribe_in.sites:
|
if subscribe_in.sites is not None:
|
||||||
subscribe_in.sites = json.dumps(subscribe_in.sites)
|
subscribe_in.sites = json.dumps(subscribe_in.sites)
|
||||||
# 避免更新缺失集数
|
# 避免更新缺失集数
|
||||||
subscribe_dict = subscribe_in.dict()
|
subscribe_dict = subscribe_in.dict()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from typing import Optional, List, Tuple
|
|||||||
from app.chain import ChainBase
|
from app.chain import ChainBase
|
||||||
from app.core.context import Context, MediaInfo
|
from app.core.context import Context, MediaInfo
|
||||||
from app.core.meta import MetaBase
|
from app.core.meta import MetaBase
|
||||||
from app.core.metainfo import MetaInfo
|
from app.core.metainfo import MetaInfo, MetaInfoPath
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.utils.string import StringUtils
|
from app.utils.string import StringUtils
|
||||||
|
|
||||||
@@ -38,12 +38,8 @@ class MediaChain(ChainBase):
|
|||||||
"""
|
"""
|
||||||
logger.info(f'开始识别媒体信息,文件:{path} ...')
|
logger.info(f'开始识别媒体信息,文件:{path} ...')
|
||||||
file_path = Path(path)
|
file_path = Path(path)
|
||||||
# 上级目录元数据
|
# 元数据
|
||||||
dir_meta = MetaInfo(title=file_path.parent.name)
|
file_meta = MetaInfoPath(file_path)
|
||||||
# 文件元数据,不包含后缀
|
|
||||||
file_meta = MetaInfo(title=file_path.stem)
|
|
||||||
# 合并元数据
|
|
||||||
file_meta.merge(dir_meta)
|
|
||||||
# 识别媒体信息
|
# 识别媒体信息
|
||||||
mediainfo = self.recognize_media(meta=file_meta)
|
mediainfo = self.recognize_media(meta=file_meta)
|
||||||
if not mediainfo:
|
if not mediainfo:
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from app.chain.media import MediaChain
|
|||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.context import MediaInfo
|
from app.core.context import MediaInfo
|
||||||
from app.core.meta import MetaBase
|
from app.core.meta import MetaBase
|
||||||
from app.core.metainfo import MetaInfo
|
from app.core.metainfo import MetaInfoPath
|
||||||
from app.db.downloadhistory_oper import DownloadHistoryOper
|
from app.db.downloadhistory_oper import DownloadHistoryOper
|
||||||
from app.db.models.downloadhistory import DownloadHistory
|
from app.db.models.downloadhistory import DownloadHistory
|
||||||
from app.db.models.transferhistory import TransferHistory
|
from app.db.models.transferhistory import TransferHistory
|
||||||
@@ -202,12 +202,8 @@ class TransferChain(ChainBase):
|
|||||||
key=ProgressKey.FileTransfer)
|
key=ProgressKey.FileTransfer)
|
||||||
|
|
||||||
if not meta:
|
if not meta:
|
||||||
# 上级目录元数据
|
# 文件元数据
|
||||||
dir_meta = MetaInfo(title=file_path.parent.name)
|
file_meta = MetaInfoPath(file_path)
|
||||||
# 文件元数据,不包含后缀
|
|
||||||
file_meta = MetaInfo(title=file_path.stem)
|
|
||||||
# 合并元数据
|
|
||||||
file_meta.merge(dir_meta)
|
|
||||||
else:
|
else:
|
||||||
file_meta = meta
|
file_meta = meta
|
||||||
|
|
||||||
@@ -474,7 +470,8 @@ class TransferChain(ChainBase):
|
|||||||
text=errmsg, userid=userid))
|
text=errmsg, userid=userid))
|
||||||
return
|
return
|
||||||
|
|
||||||
def re_transfer(self, logid: int, mtype: MediaType, tmdbid: int) -> Tuple[bool, str]:
|
def re_transfer(self, logid: int,
|
||||||
|
mtype: MediaType = None, tmdbid: int = None) -> Tuple[bool, str]:
|
||||||
"""
|
"""
|
||||||
根据历史记录,重新识别转移,只处理对应的src目录
|
根据历史记录,重新识别转移,只处理对应的src目录
|
||||||
:param logid: 历史记录ID
|
:param logid: 历史记录ID
|
||||||
@@ -492,11 +489,15 @@ class TransferChain(ChainBase):
|
|||||||
return False, f"源目录不存在:{src_path}"
|
return False, f"源目录不存在:{src_path}"
|
||||||
dest_path = Path(history.dest) if history.dest else None
|
dest_path = Path(history.dest) if history.dest else None
|
||||||
# 查询媒体信息
|
# 查询媒体信息
|
||||||
mediainfo = self.recognize_media(mtype=mtype, tmdbid=tmdbid)
|
if mtype and tmdbid:
|
||||||
|
mediainfo = self.recognize_media(mtype=mtype, tmdbid=tmdbid)
|
||||||
|
else:
|
||||||
|
meta = MetaInfoPath(src_path)
|
||||||
|
mediainfo = self.recognize_media(meta=meta)
|
||||||
if not mediainfo:
|
if not mediainfo:
|
||||||
return False, f"未识别到媒体信息,类型:{mtype.value},tmdbid:{tmdbid}"
|
return False, f"未识别到媒体信息,类型:{mtype.value},tmdbid:{tmdbid}"
|
||||||
# 重新执行转移
|
# 重新执行转移
|
||||||
logger.info(f"{mtype.value} {tmdbid} 识别为:{mediainfo.title_year}")
|
logger.info(f"{src_path.name} 识别为:{mediainfo.title_year}")
|
||||||
# 更新媒体图片
|
# 更新媒体图片
|
||||||
self.obtain_images(mediainfo=mediainfo)
|
self.obtain_images(mediainfo=mediainfo)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from app.core.meta.words import WordsMatcher
|
|||||||
|
|
||||||
def MetaInfo(title: str, subtitle: str = None) -> MetaBase:
|
def MetaInfo(title: str, subtitle: str = None) -> MetaBase:
|
||||||
"""
|
"""
|
||||||
媒体整理入口,根据名称和副标题,判断是哪种类型的识别,返回对应对象
|
根据标题和副标题识别元数据
|
||||||
:param title: 标题、种子名、文件名
|
:param title: 标题、种子名、文件名
|
||||||
:param subtitle: 副标题、描述
|
:param subtitle: 副标题、描述
|
||||||
:return: MetaAnime、MetaVideo
|
:return: MetaAnime、MetaVideo
|
||||||
@@ -33,6 +33,20 @@ def MetaInfo(title: str, subtitle: str = None) -> MetaBase:
|
|||||||
return meta
|
return meta
|
||||||
|
|
||||||
|
|
||||||
|
def MetaInfoPath(path: Path) -> MetaBase:
|
||||||
|
"""
|
||||||
|
根据路径识别元数据
|
||||||
|
:param path: 路径
|
||||||
|
"""
|
||||||
|
# 上级目录元数据
|
||||||
|
dir_meta = MetaInfo(title=path.parent.name)
|
||||||
|
# 文件元数据,不包含后缀
|
||||||
|
file_meta = MetaInfo(title=path.stem)
|
||||||
|
# 合并元数据
|
||||||
|
file_meta.merge(dir_meta)
|
||||||
|
return file_meta
|
||||||
|
|
||||||
|
|
||||||
def is_anime(name: str) -> bool:
|
def is_anime(name: str) -> bool:
|
||||||
"""
|
"""
|
||||||
判断是否为动漫
|
判断是否为动漫
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class BrushFlow(_PluginBase):
|
|||||||
# 加载顺序
|
# 加载顺序
|
||||||
plugin_order = 21
|
plugin_order = 21
|
||||||
# 可使用的用户级别
|
# 可使用的用户级别
|
||||||
auth_level = 3
|
auth_level = 2
|
||||||
|
|
||||||
# 私有属性
|
# 私有属性
|
||||||
siteshelper = None
|
siteshelper = None
|
||||||
@@ -1265,12 +1265,6 @@ class BrushFlow(_PluginBase):
|
|||||||
f"{task.get('site_name')}{task.get('title')}" for task in task_info.values()
|
f"{task.get('site_name')}{task.get('title')}" for task in task_info.values()
|
||||||
]:
|
]:
|
||||||
continue
|
continue
|
||||||
# 保种体积(GB) 促销
|
|
||||||
if self._disksize \
|
|
||||||
and (torrents_size + torrent.size) > float(self._disksize) * 1024**3:
|
|
||||||
logger.warn(f"当前做种体积 {StringUtils.str_filesize(torrents_size)} "
|
|
||||||
f"已超过保种体积 {self._disksize},停止新增任务")
|
|
||||||
break
|
|
||||||
# 促销
|
# 促销
|
||||||
if self._freeleech and torrent.downloadvolumefactor != 0:
|
if self._freeleech and torrent.downloadvolumefactor != 0:
|
||||||
continue
|
continue
|
||||||
@@ -1349,6 +1343,12 @@ class BrushFlow(_PluginBase):
|
|||||||
logger.warn(f"当前总下载带宽 {StringUtils.str_filesize(current_download_speed)} "
|
logger.warn(f"当前总下载带宽 {StringUtils.str_filesize(current_download_speed)} "
|
||||||
f"已达到最大值 {self._maxdlspeed} KB/s,暂时停止新增任务")
|
f"已达到最大值 {self._maxdlspeed} KB/s,暂时停止新增任务")
|
||||||
break
|
break
|
||||||
|
# 保种体积(GB)
|
||||||
|
if self._disksize \
|
||||||
|
and (torrents_size + torrent.size) > float(self._disksize) * 1024**3:
|
||||||
|
logger.warn(f"当前做种体积 {StringUtils.str_filesize(torrents_size)} "
|
||||||
|
f"已超过保种体积 {self._disksize},停止新增任务")
|
||||||
|
break
|
||||||
# 添加下载任务
|
# 添加下载任务
|
||||||
hash_string = self.__download(torrent=torrent)
|
hash_string = self.__download(torrent=torrent)
|
||||||
if not hash_string:
|
if not hash_string:
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from watchdog.observers.polling import PollingObserver
|
|||||||
from app.chain.transfer import TransferChain
|
from app.chain.transfer import TransferChain
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.context import MediaInfo
|
from app.core.context import MediaInfo
|
||||||
from app.core.metainfo import MetaInfo
|
from app.core.metainfo import MetaInfoPath
|
||||||
from app.db.downloadhistory_oper import DownloadHistoryOper
|
from app.db.downloadhistory_oper import DownloadHistoryOper
|
||||||
from app.db.transferhistory_oper import TransferHistoryOper
|
from app.db.transferhistory_oper import TransferHistoryOper
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
@@ -237,13 +237,8 @@ class DirMonitor(_PluginBase):
|
|||||||
logger.info(f"{event_path} 已整理过")
|
logger.info(f"{event_path} 已整理过")
|
||||||
return
|
return
|
||||||
|
|
||||||
# 上级目录元数据
|
# 元数据
|
||||||
meta = MetaInfo(title=file_path.parent.name)
|
file_meta = MetaInfoPath(file_path)
|
||||||
# 文件元数据,不包含后缀
|
|
||||||
file_meta = MetaInfo(title=file_path.stem)
|
|
||||||
# 合并元数据
|
|
||||||
file_meta.merge(meta)
|
|
||||||
|
|
||||||
if not file_meta.name:
|
if not file_meta.name:
|
||||||
logger.error(f"{file_path.name} 无法识别有效信息")
|
logger.error(f"{file_path.name} 无法识别有效信息")
|
||||||
return
|
return
|
||||||
@@ -343,7 +338,7 @@ class DirMonitor(_PluginBase):
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
# 发送消息汇总
|
# 发送消息汇总
|
||||||
media_list = self._medias.get(mediainfo.title_year + " " + meta.season) or {}
|
media_list = self._medias.get(mediainfo.title_year + " " + file_meta.season) or {}
|
||||||
if media_list:
|
if media_list:
|
||||||
media_files = media_list.get("files") or []
|
media_files = media_list.get("files") or []
|
||||||
if media_files:
|
if media_files:
|
||||||
@@ -384,7 +379,7 @@ class DirMonitor(_PluginBase):
|
|||||||
],
|
],
|
||||||
"time": datetime.now()
|
"time": datetime.now()
|
||||||
}
|
}
|
||||||
self._medias[mediainfo.title_year + " " + meta.season] = media_list
|
self._medias[mediainfo.title_year + " " + file_meta.season] = media_list
|
||||||
|
|
||||||
# 汇总刷新媒体库
|
# 汇总刷新媒体库
|
||||||
if settings.REFRESH_MEDIASERVER:
|
if settings.REFRESH_MEDIASERVER:
|
||||||
|
|||||||
@@ -61,7 +61,9 @@ class SystemUtils:
|
|||||||
移动
|
移动
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
# 当前目录改名
|
||||||
temp = src.replace(src.parent / dest.name)
|
temp = src.replace(src.parent / dest.name)
|
||||||
|
# 移动到目标目录
|
||||||
shutil.move(temp, dest)
|
shutil.move(temp, dest)
|
||||||
return 0, ""
|
return 0, ""
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
@@ -74,7 +76,11 @@ class SystemUtils:
|
|||||||
硬链接
|
硬链接
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
dest.hardlink_to(src)
|
# link到当前目录并改名
|
||||||
|
tmp_path = src.parent / dest.name
|
||||||
|
tmp_path.hardlink_to(src)
|
||||||
|
# 移动到目标目录
|
||||||
|
shutil.move(tmp_path, dest)
|
||||||
return 0, ""
|
return 0, ""
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(str(err))
|
print(str(err))
|
||||||
@@ -343,9 +349,9 @@ class SystemUtils:
|
|||||||
# 获取当前容器的 ID
|
# 获取当前容器的 ID
|
||||||
with open('/proc/self/mountinfo', 'r') as f:
|
with open('/proc/self/mountinfo', 'r') as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
index_resolv_conf = data.find("/sys/fs/cgroup/devices")
|
index_resolv_conf = data.find("resolv.conf")
|
||||||
if index_resolv_conf != -1:
|
if index_resolv_conf != -1:
|
||||||
index_second_slash = data.rfind(" ", 0, index_resolv_conf)
|
index_second_slash = data.rfind("/", 0, index_resolv_conf)
|
||||||
index_first_slash = data.rfind("/", 0, index_second_slash) + 1
|
index_first_slash = data.rfind("/", 0, index_second_slash) + 1
|
||||||
container_id = data[index_first_slash:index_second_slash]
|
container_id = data[index_first_slash:index_second_slash]
|
||||||
if not container_id:
|
if not container_id:
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
APP_VERSION = 'v1.2.5'
|
APP_VERSION = 'v1.2.6'
|
||||||
|
|||||||
Reference in New Issue
Block a user