@@ -221,25 +221,23 @@ async def add(self, torrent_url, save_path, category) -> str | None:
221221 logger .debug (
222222 f"[QbDownloader] Starting to get torrent content from { torrent_url } "
223223 )
224- async with RequestContent () as req :
225- logger .debug (f"[QbDownloader] Calling get_content for { torrent_url } " )
226- if torrent_file := await req .get_content (torrent_url ):
227- logger .debug (
228- f"[QbDownloader] Got torrent content, getting hash for { torrent_url } "
229- )
230- torrent_hashes = await req .get_torrent_hash (torrent_url )
231- # 优先使用v2 hash,如果没有则使用v1 hash
232- torrent_link = torrent_hashes .get ("v2" , torrent_hashes .get ("v1" , "" ))
233- logger .debug (f"[QbDownloader] Got torrent hashes: { torrent_hashes } " )
234- logger .debug (f"[QbDownloader] Using hash: { torrent_link } " )
235- file = {"torrents" : torrent_file }
236- else :
237- logger .warning (
238- f"[QbDownloader] Failed to get torrent content from { torrent_url } "
239- )
240- logger .debug (
241- "[QbDownloader] Finished getting torrent content, proceeding to add torrent"
242- )
224+ if not torrent_url .startswith ("magnet:" ):
225+ async with RequestContent () as req :
226+ logger .debug (f"[QbDownloader] Calling get_content for { torrent_url } " )
227+ if torrent_file := await req .get_content (torrent_url ):
228+ logger .debug (
229+ f"[QbDownloader] Got torrent content, getting hash for { torrent_url } "
230+ )
231+ torrent_hashes = await req .get_torrent_hash (torrent_url )
232+ # 优先使用v2 hash,如果没有则使用v1 hash
233+ torrent_link = torrent_hashes .get ("v2" , torrent_hashes .get ("v1" , "" ))
234+ logger .debug (f"[QbDownloader] Got torrent hashes: { torrent_hashes } " )
235+ logger .debug (f"[QbDownloader] Using hash: { torrent_link } " )
236+ file = {"torrents" : torrent_file }
237+ else :
238+ logger .warning (
239+ f"[QbDownloader] Failed to get torrent content from { torrent_url } "
240+ )
243241 try :
244242 resp = await self ._client .post (
245243 url = QB_API_URL ["add" ],
0 commit comments