Skip to content

Commit 3bebc22

Browse files
committed
fix #118
1 parent 71c3dbc commit 3bebc22

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

app/api/endpoints/history.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from app.db import get_db
1111
from app.db.models.downloadhistory import DownloadHistory
1212
from app.db.models.transferhistory import TransferHistory
13+
from app.schemas import MediaType
1314

1415
router = APIRouter()
1516

@@ -81,13 +82,14 @@ def delete_transfer_history(history_in: schemas.TransferHistory,
8182

8283
@router.post("/transfer", summary="历史记录重新转移", response_model=schemas.Response)
8384
def redo_transfer_history(history_in: schemas.TransferHistory,
85+
mtype: str,
8486
new_tmdbid: int,
8587
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
8688
"""
8789
历史记录重新转移
8890
"""
8991
hash_str = history_in.download_hash
90-
result = TransferChain().process(f"{hash_str} {new_tmdbid}")
92+
result = TransferChain().process(f"{hash_str} {new_tmdbid}|{mtype}")
9193
if result:
9294
return schemas.Response(success=True)
9395
else:

app/chain/transfer.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self):
3737
def process(self, arg_str: str = None, channel: MessageChannel = None, userid: Union[str, int] = None) -> bool:
3838
"""
3939
获取下载器中的种子列表,并执行转移
40-
:param arg_str: 传入的参数 (种子hash和TMDB ID)
40+
:param arg_str: 传入的参数 (种子hash和TMDBID|类型)
4141
:param channel: 消息通道
4242
:param userid: 用户ID
4343
"""
@@ -59,6 +59,13 @@ def extract_hash_and_number(string: str):
5959
with lock:
6060
if arg_str:
6161
logger.info(f"开始转移下载器文件,参数:{arg_str}")
62+
# 解析中附带的类型
63+
args = arg_str.split('|')
64+
if len(args) > 1:
65+
mtype = MediaType(args[-1])
66+
arg_str = args[0]
67+
else:
68+
mtype = None
6269
# 解析中种子hash,TMDB ID
6370
torrent_hash, tmdbid = extract_hash_and_number(arg_str)
6471
if not hash or not tmdbid:
@@ -67,10 +74,10 @@ def extract_hash_and_number(string: str):
6774
# 获取种子
6875
torrents: Optional[List[TransferTorrent]] = self.list_torrents(hashs=torrent_hash)
6976
if not torrents:
70-
logger.error(f"没有获取到种子,参数:{arg_str}")
77+
logger.error(f"没有获取到种子,参数:{torrent_hash}")
7178
return False
7279
# 查询媒体信息
73-
arg_mediainfo = self.recognize_media(tmdbid=tmdbid)
80+
arg_mediainfo = self.recognize_media(mtype=mtype, tmdbid=tmdbid)
7481
else:
7582
arg_mediainfo = None
7683
logger.info("开始执行下载器文件转移 ...")
@@ -123,7 +130,7 @@ def extract_hash_and_number(string: str):
123130
channel=channel,
124131
mtype=NotificationType.Manual,
125132
title=f"{torrent.title} 未识别到媒体信息,无法入库!\n"
126-
f"回复:```\n/transfer {torrent.hash} [tmdbid]\n``` 手动识别转移。",
133+
f"回复:```\n/transfer {torrent.hash} [tmdbid]|[类型]\n``` 手动识别转移。",
127134
userid=userid))
128135
# 新增转移失败历史记录
129136
self.transferhis.add(

0 commit comments

Comments
 (0)