Handle magnet links in torrent parsing and downloader modules (#4815)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: jxxghp <jxxghp@live.cn>
This commit is contained in:
jxxghp
2025-08-23 10:51:32 +08:00
committed by GitHub
parent cd8f7e72e0
commit 4699f511bf
3 changed files with 31 additions and 2 deletions

View File

@@ -201,6 +201,15 @@ class TorrentHelper(metaclass=WeakSingleton):
"""
if not torrent_content:
return "", []
# 检查是否为磁力链接
if isinstance(torrent_content, str) and torrent_content.startswith("magnet:"):
# 磁力链接无法预先获取文件信息,返回空
return "", []
elif isinstance(torrent_content, bytes) and torrent_content.startswith(b"magnet:"):
# 磁力链接无法预先获取文件信息,返回空
return "", []
try:
# 解析种子内容
torrentinfo = Torrent.from_string(torrent_content)