Spaces:
Sleeping
Sleeping
import libtorrent as lt | |
import time | |
import streamlit as st | |
st.title('磁力链接 BT 下载器') | |
magnet_link = st.text_input('请输入磁力链接:') | |
if magnet_link: | |
ses = lt.session() | |
h = lt.add_magnet_uri(ses, magnet_link, {'save_path': './'}) | |
st.write('开始下载...') | |
while not h.is_seed(): | |
s = h.status() | |
state_str = [ | |
"queued", | |
"checking", | |
"downloading metadata", | |
"downloading", | |
"finished", | |
"seeding", | |
"allocating", | |
"checking fastresume", | |
] | |
st.write( | |
f"进度: {s.progress * 100:.2f}%,速度: {s.download_rate / 1000:.2f} KB/s,状态:{state_str[s.state]}" | |
) | |
time.sleep(1) | |
st.write('下载完成') | |