Ethscriptions commited on
Commit
4f989ff
·
1 Parent(s): 7a7e5fa

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import libtorrent as lt
2
+ import time
3
+ import streamlit as st
4
+
5
+ st.title('磁力链接 BT 下载器')
6
+
7
+ magnet_link = st.text_input('请输入磁力链接:')
8
+
9
+ if magnet_link:
10
+ ses = lt.session()
11
+ h = lt.add_magnet_uri(ses, magnet_link, {'save_path': './'})
12
+ st.write('开始下载...')
13
+
14
+ while not h.is_seed():
15
+ s = h.status()
16
+ state_str = [
17
+ "queued",
18
+ "checking",
19
+ "downloading metadata",
20
+ "downloading",
21
+ "finished",
22
+ "seeding",
23
+ "allocating",
24
+ "checking fastresume",
25
+ ]
26
+ st.write(
27
+ f"进度: {s.progress * 100:.2f}%,速度: {s.download_rate / 1000:.2f} KB/s,状态:{state_str[s.state]}"
28
+ )
29
+ time.sleep(1)
30
+
31
+ st.write('下载完成')