Skip to content

Commit

Permalink
🐛 修复 BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
Quan666 committed Mar 29, 2021
1 parent fbf49ac commit af72ffb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/plugins/ELF_RSS2/RSS/my_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


# 检测某个rss更新 #任务体
@util.time_out(time=20) # 20s 任务超时时间
@util.time_out(time=300) # 20s 任务超时时间
async def check_update(rss: rss_class.rss):
logger.info('{} 检查更新'.format(rss.name))
await rss_parsing.start(rss)
Expand Down
39 changes: 23 additions & 16 deletions src/plugins/ELF_RSS2/RSS/qbittorrent_download.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import base64
import datetime
import re
import time

import httpx
Expand Down Expand Up @@ -113,22 +114,28 @@ async def get_Hash_Name(url: str, proxy=None) -> dict:
proxy = {}
qb = await get_qb()
info = None
async with httpx.AsyncClient(proxies=proxy) as client:
try:
res = await client.get(url, timeout=100)
qb.download_from_file(res.content)
hash = get_torrent_b16Hash(res.content)
while not info:
for tmp_torrent in qb.torrents():
if tmp_torrent['hash'] == hash:
info = {
'hash': tmp_torrent['hash'],
'filename': tmp_torrent['name'],
'size': getSize(tmp_torrent['size'])
}
await asyncio.sleep(1)
except Exception as e:
await send_Msg('下载种子失败,可能需要代理:{}'.format(e))
if re.search("magnet:\?xt=urn:btih:",url) :
qb.download_from_link(link=url)
hash = re.search('[a-f0-9]{40}',url)[0]
else:
async with httpx.AsyncClient(proxies=proxy) as client:
try:
res = await client.get(url, timeout=100)
qb.download_from_file(res.content)
hash = get_torrent_b16Hash(res.content)
except Exception as e:
await send_Msg('下载种子失败,可能需要代理:{}'.format(e))
return None

while not info:
for tmp_torrent in qb.torrents():
if tmp_torrent['hash'] == hash and tmp_torrent['size']:
info = {
'hash': tmp_torrent['hash'],
'filename': tmp_torrent['name'],
'size': getSize(tmp_torrent['size'])
}
await asyncio.sleep(1)
return info


Expand Down

0 comments on commit af72ffb

Please sign in to comment.