Spaces:
Build error
Build error
Commit
·
22ba115
1
Parent(s):
e43315a
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import libtorrent as lt
|
| 2 |
import time
|
| 3 |
import streamlit as st
|
|
|
|
| 4 |
|
| 5 |
st.title('磁力链接 BT 下载器')
|
| 6 |
|
|
@@ -29,3 +30,17 @@ if magnet_link:
|
|
| 29 |
time.sleep(1)
|
| 30 |
|
| 31 |
st.write('下载完成')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import libtorrent as lt
|
| 2 |
import time
|
| 3 |
import streamlit as st
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
st.title('磁力链接 BT 下载器')
|
| 7 |
|
|
|
|
| 30 |
time.sleep(1)
|
| 31 |
|
| 32 |
st.write('下载完成')
|
| 33 |
+
|
| 34 |
+
# 获取下载的文件名
|
| 35 |
+
torrent_info = h.get_torrent_info()
|
| 36 |
+
files = torrent_info.files()
|
| 37 |
+
filepath = f"./{files.file_path(0)}"
|
| 38 |
+
|
| 39 |
+
# 提供一个下载按钮给用户下载文件
|
| 40 |
+
with open(filepath, "rb") as file:
|
| 41 |
+
btn = st.download_button(
|
| 42 |
+
label="下载文件",
|
| 43 |
+
data=file,
|
| 44 |
+
file_name=os.path.basename(filepath),
|
| 45 |
+
mime="application/octet-stream",
|
| 46 |
+
)
|