Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -414,8 +414,7 @@ def create_gradio_interface():
|
|
414 |
return report_path
|
415 |
return None
|
416 |
|
417 |
-
|
418 |
-
# Gradio Interface
|
419 |
downloaded_dois_html = gr.HTML(label="""
|
420 |
<div style='padding-bottom: 5px; font-weight: bold;'>
|
421 |
Enter Single DOI
|
@@ -435,51 +434,40 @@ def create_gradio_interface():
|
|
435 |
<div id="failed-dois"></div>
|
436 |
</div>
|
437 |
""")
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
473 |
-
}
|
474 |
-
.output-text a {
|
475 |
-
color: #007bff; /* Blue color for hyperlinks */
|
476 |
-
}
|
477 |
-
""",
|
478 |
-
cache_examples = False,
|
479 |
-
)
|
480 |
-
|
481 |
-
# Add Javascript to update HTML
|
482 |
-
interface.load = """
|
483 |
function(downloaded_dois, failed_dois){
|
484 |
let downloaded_html = '<ul>';
|
485 |
downloaded_dois.split('\\n').filter(Boolean).forEach(doi => {
|
@@ -497,12 +485,14 @@ def create_gradio_interface():
|
|
497 |
return [downloaded_html, failed_html];
|
498 |
|
499 |
}
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
|
|
|
|
506 |
report_button.click(create_report, inputs = [downloaded_dois_html,failed_dois_html], outputs=report_output)
|
507 |
|
508 |
return interface
|
|
|
414 |
return report_path
|
415 |
return None
|
416 |
|
417 |
+
|
|
|
418 |
downloaded_dois_html = gr.HTML(label="""
|
419 |
<div style='padding-bottom: 5px; font-weight: bold;'>
|
420 |
Enter Single DOI
|
|
|
434 |
<div id="failed-dois"></div>
|
435 |
</div>
|
436 |
""")
|
437 |
+
|
438 |
+
with gr.Blocks(theme="Hev832/Applio") as interface:
|
439 |
+
gr.Markdown("""# 🔬 Academic Paper Batch Downloader""")
|
440 |
+
gr.Markdown("Upload a BibTeX file or enter DOIs to download PDFs. We'll attempt to fetch PDFs from multiple sources like Sci-Hub, Libgen, Google Scholar and Crossref. You can use any of the three inputs at any moment.")
|
441 |
+
with gr.Row():
|
442 |
+
with gr.Column():
|
443 |
+
bib_file_input = gr.File(file_types=['.bib'], label="Upload BibTeX File")
|
444 |
+
doi_input = gr.Textbox(label="Enter Single DOI", placeholder="10.xxxx/xxxx")
|
445 |
+
dois_input = gr.Textbox(label="Enter Multiple DOIs (one per line)", placeholder="10.xxxx/xxxx\n10.yyyy/yyyy\n...")
|
446 |
+
|
447 |
+
with gr.Row():
|
448 |
+
clear_button = gr.Button("Clear")
|
449 |
+
submit_button = gr.Button("Submit")
|
450 |
+
|
451 |
+
with gr.Accordion("Examples"):
|
452 |
+
gr.Examples(
|
453 |
+
examples=[
|
454 |
+
["example.bib", None, None], # Bibtex File
|
455 |
+
[None, "10.1038/nature12373", None], # Single DOI
|
456 |
+
[None, None, "10.1109/5.771073\n10.3390/horticulturae8080677"], # Multiple DOIs
|
457 |
+
],
|
458 |
+
inputs=[bib_file_input, doi_input, dois_input]
|
459 |
+
)
|
460 |
+
|
461 |
+
with gr.Column():
|
462 |
+
file_output = gr.File(label="Download Papers (ZIP) or Single PDF")
|
463 |
+
downloaded_dois_html
|
464 |
+
failed_dois_html
|
465 |
+
single_pdf_output = gr.File(label="Downloaded Single PDF")
|
466 |
+
with gr.Row():
|
467 |
+
report_button = gr.Button("Create Report")
|
468 |
+
report_output = gr.File(label="Download Report")
|
469 |
+
|
470 |
+
interface.load = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
471 |
function(downloaded_dois, failed_dois){
|
472 |
let downloaded_html = '<ul>';
|
473 |
downloaded_dois.split('\\n').filter(Boolean).forEach(doi => {
|
|
|
485 |
return [downloaded_html, failed_html];
|
486 |
|
487 |
}
|
488 |
+
"""
|
489 |
+
|
490 |
+
submit_button.click(
|
491 |
+
download_papers,
|
492 |
+
inputs=[bib_file_input, doi_input, dois_input],
|
493 |
+
outputs=[file_output, downloaded_dois_html, failed_dois_html, single_pdf_output],
|
494 |
+
)
|
495 |
+
|
496 |
report_button.click(create_report, inputs = [downloaded_dois_html,failed_dois_html], outputs=report_output)
|
497 |
|
498 |
return interface
|