Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,41 +5,100 @@ from eh_logic import run_eh_download
|
|
| 5 |
# --- 界面构建 ---
|
| 6 |
with gr.Blocks(title="二次元聚合下载器") as demo:
|
| 7 |
gr.Markdown("## 📦 二次元聚合下载器 (JMComic + E-Hentai)")
|
| 8 |
-
|
|
|
|
| 9 |
with gr.Tabs():
|
| 10 |
|
| 11 |
-
# === JMComic Tab
|
| 12 |
-
with gr.TabItem("🦄 JMComic"):
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
with gr.Row():
|
| 21 |
-
eh_url = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
with gr.Row():
|
| 24 |
-
# 🔴 新增:画质滑块
|
| 25 |
eh_quality = gr.Slider(
|
| 26 |
minimum=10, maximum=100, value=75, step=5,
|
| 27 |
-
label="PDF 画质压缩 (100=原图无损, 75=推荐均衡
|
| 28 |
-
info="数值越小文件越小
|
| 29 |
)
|
| 30 |
-
|
| 31 |
with gr.Row():
|
| 32 |
-
eh_cookie = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
eh_btn = gr.Button("🚀 开始下载", variant="primary")
|
| 35 |
|
| 36 |
with gr.Row():
|
| 37 |
eh_badge = gr.Label(value="Ready", label="状态")
|
| 38 |
-
eh_log = gr.Textbox(label="日志", lines=5)
|
| 39 |
|
| 40 |
-
eh_files = gr.File(label="结果")
|
| 41 |
|
| 42 |
-
# 🔴 记得把 eh_quality 传进去
|
| 43 |
eh_btn.click(
|
| 44 |
fn=run_eh_download,
|
| 45 |
inputs=[eh_url, eh_cookie, eh_quality],
|
|
|
|
| 5 |
# --- 界面构建 ---
|
| 6 |
with gr.Blocks(title="二次元聚合下载器") as demo:
|
| 7 |
gr.Markdown("## 📦 二次元聚合下载器 (JMComic + E-Hentai)")
|
| 8 |
+
gr.Markdown("支持多线程下载、自动合并 PDF、智能画质压缩。")
|
| 9 |
+
|
| 10 |
with gr.Tabs():
|
| 11 |
|
| 12 |
+
# ================= JMComic Tab =================
|
| 13 |
+
with gr.TabItem("🦄 JMComic (ID下载)"):
|
| 14 |
+
gr.Markdown("一行一个 ID,下载完一个才会开始下一个,稳定防崩。")
|
| 15 |
+
|
| 16 |
+
with gr.Row():
|
| 17 |
+
jm_inp_ids = gr.Textbox(
|
| 18 |
+
label="输入本子 ID 列表 (回车分隔)",
|
| 19 |
+
placeholder="438696\n123456",
|
| 20 |
+
lines=5
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
with gr.Row():
|
| 24 |
+
# ✨ JM 也加上了画质滑块
|
| 25 |
+
jm_quality = gr.Slider(
|
| 26 |
+
minimum=10, maximum=100, value=75, step=5,
|
| 27 |
+
label="PDF 画质压缩 (100=原图无损, 75=推荐均衡)",
|
| 28 |
+
info="JM原图通常很大,建议设置 75 以大幅节省体积。"
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
with gr.Row():
|
| 32 |
+
jm_auth_select = gr.Radio(
|
| 33 |
+
["使用账号密码 (推荐)", "使用 Cookies (手动)"],
|
| 34 |
+
label="登录方式",
|
| 35 |
+
value="使用账号密码 (推荐)"
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
with gr.Group(visible=True) as group_user:
|
| 39 |
+
with gr.Row():
|
| 40 |
+
jm_inp_user = gr.Textbox(label="用户名", placeholder="JM账号")
|
| 41 |
+
jm_inp_pass = gr.Textbox(label="密码", type="password")
|
| 42 |
+
|
| 43 |
+
with gr.Group(visible=False) as group_cookie:
|
| 44 |
+
jm_inp_cookie = gr.Textbox(label="Cookies", placeholder="key=value...")
|
| 45 |
|
| 46 |
+
def toggle_auth(choice):
|
| 47 |
+
if choice == "使用账号密码 (推荐)":
|
| 48 |
+
return gr.update(visible=True), gr.update(visible=False)
|
| 49 |
+
else:
|
| 50 |
+
return gr.update(visible=False), gr.update(visible=True)
|
| 51 |
+
|
| 52 |
+
jm_auth_select.change(fn=toggle_auth, inputs=jm_auth_select, outputs=[group_user, group_cookie])
|
| 53 |
+
|
| 54 |
+
jm_btn = gr.Button("🚀 开始下载 (JM)", variant="primary")
|
| 55 |
+
|
| 56 |
+
with gr.Row():
|
| 57 |
+
jm_badge = gr.Label(value="Ready", label="状态")
|
| 58 |
+
jm_log = gr.Textbox(label="运行日志", lines=5)
|
| 59 |
+
|
| 60 |
+
jm_files = gr.File(label="下载结果", file_count="multiple")
|
| 61 |
+
|
| 62 |
+
# 🔴 记得传入 jm_quality
|
| 63 |
+
jm_btn.click(
|
| 64 |
+
fn=run_jm_download,
|
| 65 |
+
inputs=[jm_inp_ids, jm_auth_select, jm_inp_cookie, jm_inp_user, jm_inp_pass, jm_quality],
|
| 66 |
+
outputs=[jm_files, jm_log, jm_badge]
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
# ================= E-Hentai Tab =================
|
| 70 |
+
with gr.TabItem("🐼 E-Hentai (链接下载)"):
|
| 71 |
+
gr.Markdown("**提示**:必须填写 Cookies (Netscape格式) 才能下载 EX 站或原图。")
|
| 72 |
|
| 73 |
with gr.Row():
|
| 74 |
+
eh_url = gr.Textbox(
|
| 75 |
+
label="画廊链接 (URL)",
|
| 76 |
+
placeholder="https://e-hentai.org/g/xxxxx/yyyy/"
|
| 77 |
+
)
|
| 78 |
|
| 79 |
with gr.Row():
|
|
|
|
| 80 |
eh_quality = gr.Slider(
|
| 81 |
minimum=10, maximum=100, value=75, step=5,
|
| 82 |
+
label="PDF 画质压缩 (100=原图无损, 75=推荐均衡)",
|
| 83 |
+
info="数值越小文件越小。100为直接打包原图(速度最快),<100会进行重压缩(较慢)。"
|
| 84 |
)
|
| 85 |
+
|
| 86 |
with gr.Row():
|
| 87 |
+
eh_cookie = gr.Textbox(
|
| 88 |
+
label="Cookies (Netscape 格式)",
|
| 89 |
+
placeholder="# Netscape HTTP Cookie File\n.e-hentai.org\tTRUE\t/ ...",
|
| 90 |
+
lines=5,
|
| 91 |
+
info="请使用 Chrome 插件 'Get cookies.txt LOCALLY' 导出并在粘贴至此。"
|
| 92 |
+
)
|
| 93 |
|
| 94 |
+
eh_btn = gr.Button("🚀 开始下载 (EH)", variant="primary")
|
| 95 |
|
| 96 |
with gr.Row():
|
| 97 |
eh_badge = gr.Label(value="Ready", label="状态")
|
| 98 |
+
eh_log = gr.Textbox(label="运行日志 (自动滚动)", lines=5)
|
| 99 |
|
| 100 |
+
eh_files = gr.File(label="下载结果")
|
| 101 |
|
|
|
|
| 102 |
eh_btn.click(
|
| 103 |
fn=run_eh_download,
|
| 104 |
inputs=[eh_url, eh_cookie, eh_quality],
|