add 失败历史记录
This commit is contained in:
parent
178ac334a0
commit
66f081de98
@ -95,7 +95,7 @@ class TransferChain(ChainBase):
|
|||||||
# 识别元数据
|
# 识别元数据
|
||||||
meta: MetaBase = MetaInfo(title=title, subtitle=subtitle)
|
meta: MetaBase = MetaInfo(title=title, subtitle=subtitle)
|
||||||
if not meta.name:
|
if not meta.name:
|
||||||
logger.warn(f'未识别到元数据,标题:{title}')
|
logger.error(f'未识别到元数据,标题:{title}')
|
||||||
continue
|
continue
|
||||||
if not arg_mediainfo:
|
if not arg_mediainfo:
|
||||||
# 查询下载记录识别情况
|
# 查询下载记录识别情况
|
||||||
@ -111,6 +111,16 @@ class TransferChain(ChainBase):
|
|||||||
self.post_message(title=f"{torrent.title} 未识别到媒体信息,无法入库!\n"
|
self.post_message(title=f"{torrent.title} 未识别到媒体信息,无法入库!\n"
|
||||||
f"回复:```\n/transfer {torrent.hash} [tmdbid]\n``` 手动识别转移。",
|
f"回复:```\n/transfer {torrent.hash} [tmdbid]\n``` 手动识别转移。",
|
||||||
userid=userid)
|
userid=userid)
|
||||||
|
# 新增转移失败历史记录
|
||||||
|
self.transferhis.add(
|
||||||
|
src=str(torrent.path),
|
||||||
|
mode=settings.TRANSFER_TYPE,
|
||||||
|
seasons=meta.season,
|
||||||
|
episodes=meta.episode,
|
||||||
|
download_hash=torrent.hash,
|
||||||
|
status=0,
|
||||||
|
errmsg="未识别到媒体信息"
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
mediainfo = arg_mediainfo
|
mediainfo = arg_mediainfo
|
||||||
@ -127,9 +137,8 @@ class TransferChain(ChainBase):
|
|||||||
text=f"原因:{transferinfo.message if transferinfo else '未知'}",
|
text=f"原因:{transferinfo.message if transferinfo else '未知'}",
|
||||||
image=mediainfo.get_message_image(),
|
image=mediainfo.get_message_image(),
|
||||||
userid=userid
|
userid=userid
|
||||||
),
|
)
|
||||||
continue
|
# 新增转移失败历史记录
|
||||||
# 新增转移历史记录
|
|
||||||
self.transferhis.add(
|
self.transferhis.add(
|
||||||
src=str(torrent.path),
|
src=str(torrent.path),
|
||||||
dest=str(transferinfo.target_path),
|
dest=str(transferinfo.target_path),
|
||||||
@ -145,7 +154,29 @@ class TransferChain(ChainBase):
|
|||||||
seasons=meta.season,
|
seasons=meta.season,
|
||||||
episodes=meta.episode,
|
episodes=meta.episode,
|
||||||
image=mediainfo.get_poster_image(),
|
image=mediainfo.get_poster_image(),
|
||||||
download_hash=torrent.hash
|
download_hash=torrent.hash,
|
||||||
|
status=0,
|
||||||
|
errmsg=transferinfo.message
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
# 新增转移成功历史记录
|
||||||
|
self.transferhis.add(
|
||||||
|
src=str(torrent.path),
|
||||||
|
dest=str(transferinfo.target_path),
|
||||||
|
mode=settings.TRANSFER_TYPE,
|
||||||
|
type=mediainfo.type.value,
|
||||||
|
category=mediainfo.category,
|
||||||
|
title=mediainfo.title,
|
||||||
|
year=mediainfo.year,
|
||||||
|
tmdbid=mediainfo.tmdb_id,
|
||||||
|
imdbid=mediainfo.imdb_id,
|
||||||
|
tvdbid=mediainfo.tvdb_id,
|
||||||
|
doubanid=mediainfo.douban_id,
|
||||||
|
seasons=meta.season,
|
||||||
|
episodes=meta.episode,
|
||||||
|
image=mediainfo.get_poster_image(),
|
||||||
|
download_hash=torrent.hash,
|
||||||
|
status=1
|
||||||
)
|
)
|
||||||
# 转移完成
|
# 转移完成
|
||||||
self.transfer_completed(hashs=torrent.hash, transinfo=transferinfo)
|
self.transfer_completed(hashs=torrent.hash, transinfo=transferinfo)
|
||||||
|
@ -36,7 +36,7 @@ class TransferHistory(Base):
|
|||||||
# 海报
|
# 海报
|
||||||
image = Column(String)
|
image = Column(String)
|
||||||
# 下载器hash
|
# 下载器hash
|
||||||
download_hash = Column(String)
|
download_hash = Column(String, index=True)
|
||||||
# 转移成功状态
|
# 转移成功状态
|
||||||
status = Column(Boolean(), default=True)
|
status = Column(Boolean(), default=True)
|
||||||
# 转移失败信息
|
# 转移失败信息
|
||||||
@ -52,3 +52,7 @@ class TransferHistory(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def list_by_page(db: Session, page: int = 1, count: int = 30):
|
def list_by_page(db: Session, page: int = 1, count: int = 30):
|
||||||
return db.query(TransferHistory).offset((page - 1) * count).limit(count).all()
|
return db.query(TransferHistory).offset((page - 1) * count).limit(count).all()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_by_hash(db: Session, download_hash: str):
|
||||||
|
return db.query(TransferHistory).filter(TransferHistory.download_hash == download_hash).first()
|
||||||
|
@ -20,5 +20,8 @@ class TransferHistoryOper(DbOper):
|
|||||||
"""
|
"""
|
||||||
新增转移历史
|
新增转移历史
|
||||||
"""
|
"""
|
||||||
transferhistory = TransferHistory(**kwargs)
|
if kwargs.get("download_hash"):
|
||||||
return transferhistory.create(self._db)
|
transferhistory = TransferHistory.get_by_hash(self._db, kwargs.get("download_hash"))
|
||||||
|
if transferhistory:
|
||||||
|
transferhistory.delete(self._db, transferhistory.id)
|
||||||
|
return TransferHistory(**kwargs).create(self._db)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user