parent
5a837a4161
commit
85e5338121
@ -142,7 +142,7 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
bangumiid: int = None,
|
bangumiid: int = None,
|
||||||
cache: bool = True) -> Optional[MediaInfo]:
|
cache: bool = True) -> Optional[MediaInfo]:
|
||||||
"""
|
"""
|
||||||
识别媒体信息
|
识别媒体信息,不含Fanart图片
|
||||||
:param meta: 识别的元数据
|
:param meta: 识别的元数据
|
||||||
:param mtype: 识别的媒体类型,与tmdbid配套
|
:param mtype: 识别的媒体类型,与tmdbid配套
|
||||||
:param tmdbid: tmdbid
|
:param tmdbid: tmdbid
|
||||||
|
@ -216,6 +216,13 @@ class DownloadChain(ChainBase):
|
|||||||
_media = context.media_info
|
_media = context.media_info
|
||||||
_meta = context.meta_info
|
_meta = context.meta_info
|
||||||
|
|
||||||
|
# 补充完整的media数据
|
||||||
|
if not _media.genre_ids:
|
||||||
|
new_media = self.recognize_media(mtype=_media.type, tmdbid=_media.tmdb_id,
|
||||||
|
doubanid=_media.douban_id, bangumiid=_media.bangumi_id)
|
||||||
|
if new_media:
|
||||||
|
_media = new_media
|
||||||
|
|
||||||
# 实际下载的集数
|
# 实际下载的集数
|
||||||
download_episodes = StringUtils.format_ep(list(episodes)) if episodes else None
|
download_episodes = StringUtils.format_ep(list(episodes)) if episodes else None
|
||||||
_folder_name = ""
|
_folder_name = ""
|
||||||
|
@ -86,12 +86,15 @@ class TransferChain(ChainBase):
|
|||||||
mediainfo = self.recognize_media(mtype=mtype,
|
mediainfo = self.recognize_media(mtype=mtype,
|
||||||
tmdbid=downloadhis.tmdbid,
|
tmdbid=downloadhis.tmdbid,
|
||||||
doubanid=downloadhis.doubanid)
|
doubanid=downloadhis.doubanid)
|
||||||
|
if mediainfo:
|
||||||
|
# 补充图片
|
||||||
|
self.obtain_images(mediainfo)
|
||||||
else:
|
else:
|
||||||
# 非MoviePilot下载的任务,按文件识别
|
# 非MoviePilot下载的任务,按文件识别
|
||||||
mediainfo = None
|
mediainfo = None
|
||||||
|
|
||||||
# 执行转移
|
# 执行转移
|
||||||
self.do_transfer(storage="local", path=torrent.path,
|
self.__do_transfer(storage="local", path=torrent.path,
|
||||||
mediainfo=mediainfo, download_hash=torrent.hash)
|
mediainfo=mediainfo, download_hash=torrent.hash)
|
||||||
|
|
||||||
# 设置下载任务状态
|
# 设置下载任务状态
|
||||||
@ -100,7 +103,7 @@ class TransferChain(ChainBase):
|
|||||||
logger.info("下载器文件转移执行完成")
|
logger.info("下载器文件转移执行完成")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def do_transfer(self, storage: str, path: Path, drive_id: str = None, fileid: str = None, filetype: str = None,
|
def __do_transfer(self, storage: str, path: Path, drive_id: str = None, fileid: str = None, filetype: str = None,
|
||||||
meta: MetaBase = None, mediainfo: MediaInfo = None,
|
meta: MetaBase = None, mediainfo: MediaInfo = None,
|
||||||
download_hash: str = None,
|
download_hash: str = None,
|
||||||
target: Path = None, transfer_type: str = None,
|
target: Path = None, transfer_type: str = None,
|
||||||
@ -152,7 +155,7 @@ class TransferChain(ChainBase):
|
|||||||
download_hash=download_hash, force=force)
|
download_hash=download_hash, force=force)
|
||||||
else:
|
else:
|
||||||
# 网盘整理
|
# 网盘整理
|
||||||
result = self.__transfer_remote(storage=storage,
|
result = self.__transfer_online(storage=storage,
|
||||||
fileitem=schemas.FileItem(
|
fileitem=schemas.FileItem(
|
||||||
path=str(path) + ("/" if filetype == "dir" else ""),
|
path=str(path) + ("/" if filetype == "dir" else ""),
|
||||||
type=filetype,
|
type=filetype,
|
||||||
@ -467,7 +470,7 @@ class TransferChain(ChainBase):
|
|||||||
key=ProgressKey.FileTransfer)
|
key=ProgressKey.FileTransfer)
|
||||||
return True, "\n".join(err_msgs)
|
return True, "\n".join(err_msgs)
|
||||||
|
|
||||||
def __transfer_remote(self, storage: str, fileitem: schemas.FileItem,
|
def __transfer_online(self, storage: str, fileitem: schemas.FileItem,
|
||||||
meta: MetaBase, mediainfo: MediaInfo) -> Tuple[bool, str]:
|
meta: MetaBase, mediainfo: MediaInfo) -> Tuple[bool, str]:
|
||||||
"""
|
"""
|
||||||
整理一个远程目录
|
整理一个远程目录
|
||||||
@ -535,7 +538,7 @@ class TransferChain(ChainBase):
|
|||||||
# 文件元数据
|
# 文件元数据
|
||||||
meta = MetaInfoPath(Path(fileitem.path))
|
meta = MetaInfoPath(Path(fileitem.path))
|
||||||
if not mediainfo:
|
if not mediainfo:
|
||||||
mediainfo = self.recognize_media(meta=meta)
|
mediainfo = self.mediachain.recognize_by_meta(meta)
|
||||||
if not mediainfo:
|
if not mediainfo:
|
||||||
logger.warn(f"{fileitem.name} 未识别到媒体信息")
|
logger.warn(f"{fileitem.name} 未识别到媒体信息")
|
||||||
return False, f"{fileitem.name} 未识别到媒体信息"
|
return False, f"{fileitem.name} 未识别到媒体信息"
|
||||||
@ -589,12 +592,12 @@ class TransferChain(ChainBase):
|
|||||||
if not file_meta.name:
|
if not file_meta.name:
|
||||||
# 过滤掉无效文件
|
# 过滤掉无效文件
|
||||||
continue
|
continue
|
||||||
file_media = self.recognize_media(meta=file_meta)
|
file_media = self.mediachain.recognize_by_meta(file_meta)
|
||||||
if not file_media:
|
if not file_media:
|
||||||
logger.warn(f"{file.name} 未识别到媒体信息")
|
logger.warn(f"{file.name} 未识别到媒体信息")
|
||||||
continue
|
continue
|
||||||
# 整理这个文件或目录
|
# 整理这个文件或目录
|
||||||
self.__transfer_remote(storage=storage, fileitem=file, meta=file_meta, mediainfo=file_media)
|
self.__transfer_online(storage=storage, fileitem=file, meta=file_meta, mediainfo=file_media)
|
||||||
else:
|
else:
|
||||||
# 电视剧目录
|
# 电视剧目录
|
||||||
# 判断当前目录类型
|
# 判断当前目录类型
|
||||||
@ -661,12 +664,12 @@ class TransferChain(ChainBase):
|
|||||||
continue
|
continue
|
||||||
# 重新识别文件或目录
|
# 重新识别文件或目录
|
||||||
file_meta = MetaInfoPath(Path(file.path))
|
file_meta = MetaInfoPath(Path(file.path))
|
||||||
file_media = self.recognize_media(meta=file_meta)
|
file_media = self.mediachain.recognize_by_meta(file_meta)
|
||||||
if not file_media:
|
if not file_media:
|
||||||
logger.warn(f"{file.name} 未识别到媒体信息")
|
logger.warn(f"{file.name} 未识别到媒体信息")
|
||||||
continue
|
continue
|
||||||
# 整理这个文件或目录
|
# 整理这个文件或目录
|
||||||
self.__transfer_remote(storage=storage, fileitem=file, meta=file_meta, mediainfo=file_media)
|
self.__transfer_online(storage=storage, fileitem=file, meta=file_meta, mediainfo=file_media)
|
||||||
|
|
||||||
logger.info(f"{fileitem.path} 整理完成")
|
logger.info(f"{fileitem.path} 整理完成")
|
||||||
self.progress.update(value=0,
|
self.progress.update(value=0,
|
||||||
@ -747,7 +750,7 @@ class TransferChain(ChainBase):
|
|||||||
if not type_str or type_str not in [MediaType.MOVIE.value, MediaType.TV.value]:
|
if not type_str or type_str not in [MediaType.MOVIE.value, MediaType.TV.value]:
|
||||||
args_error()
|
args_error()
|
||||||
return
|
return
|
||||||
state, errmsg = self.re_transfer(logid=int(logid),
|
state, errmsg = self.__re_transfer(logid=int(logid),
|
||||||
mtype=MediaType(type_str),
|
mtype=MediaType(type_str),
|
||||||
mediaid=media_id)
|
mediaid=media_id)
|
||||||
if not state:
|
if not state:
|
||||||
@ -755,7 +758,7 @@ class TransferChain(ChainBase):
|
|||||||
text=errmsg, userid=userid, link=settings.MP_DOMAIN('#/history')))
|
text=errmsg, userid=userid, link=settings.MP_DOMAIN('#/history')))
|
||||||
return
|
return
|
||||||
|
|
||||||
def re_transfer(self, logid: int, mtype: MediaType = None,
|
def __re_transfer(self, logid: int, mtype: MediaType = None,
|
||||||
mediaid: str = None) -> Tuple[bool, str]:
|
mediaid: str = None) -> Tuple[bool, str]:
|
||||||
"""
|
"""
|
||||||
根据历史记录,重新识别转移,只支持简单条件
|
根据历史记录,重新识别转移,只支持简单条件
|
||||||
@ -791,7 +794,7 @@ class TransferChain(ChainBase):
|
|||||||
self.delete_files(Path(history.dest))
|
self.delete_files(Path(history.dest))
|
||||||
|
|
||||||
# 强制转移
|
# 强制转移
|
||||||
state, errmsg = self.do_transfer(storage="local",
|
state, errmsg = self.__do_transfer(storage="local",
|
||||||
path=src_path,
|
path=src_path,
|
||||||
mediainfo=mediainfo,
|
mediainfo=mediainfo,
|
||||||
download_hash=history.download_hash,
|
download_hash=history.download_hash,
|
||||||
@ -843,13 +846,16 @@ class TransferChain(ChainBase):
|
|||||||
mediainfo: MediaInfo = self.mediachain.recognize_media(tmdbid=tmdbid, doubanid=doubanid, mtype=mtype)
|
mediainfo: MediaInfo = self.mediachain.recognize_media(tmdbid=tmdbid, doubanid=doubanid, mtype=mtype)
|
||||||
if not mediainfo:
|
if not mediainfo:
|
||||||
return False, f"媒体信息识别失败,tmdbid:{tmdbid},doubanid:{doubanid},type: {mtype.value}"
|
return False, f"媒体信息识别失败,tmdbid:{tmdbid},doubanid:{doubanid},type: {mtype.value}"
|
||||||
|
else:
|
||||||
|
# 更新媒体图片
|
||||||
|
self.obtain_images(mediainfo=mediainfo)
|
||||||
# 开始进度
|
# 开始进度
|
||||||
self.progress.start(ProgressKey.FileTransfer)
|
self.progress.start(ProgressKey.FileTransfer)
|
||||||
self.progress.update(value=0,
|
self.progress.update(value=0,
|
||||||
text=f"开始转移 {in_path} ...",
|
text=f"开始转移 {in_path} ...",
|
||||||
key=ProgressKey.FileTransfer)
|
key=ProgressKey.FileTransfer)
|
||||||
# 开始转移
|
# 开始转移
|
||||||
state, errmsg = self.do_transfer(
|
state, errmsg = self.__do_transfer(
|
||||||
storage=storage,
|
storage=storage,
|
||||||
path=in_path,
|
path=in_path,
|
||||||
drive_id=drive_id,
|
drive_id=drive_id,
|
||||||
@ -872,7 +878,7 @@ class TransferChain(ChainBase):
|
|||||||
return True, ""
|
return True, ""
|
||||||
else:
|
else:
|
||||||
# 没有输入TMDBID时,按文件识别
|
# 没有输入TMDBID时,按文件识别
|
||||||
state, errmsg = self.do_transfer(storage=storage,
|
state, errmsg = self.__do_transfer(storage=storage,
|
||||||
path=in_path,
|
path=in_path,
|
||||||
drive_id=drive_id,
|
drive_id=drive_id,
|
||||||
fileid=fileid,
|
fileid=fileid,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user