Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -40,6 +40,8 @@ class PaperDownloader:
|
|
40 |
|
41 |
def clean_doi(self, doi):
|
42 |
"""Clean and encode DOI for URL"""
|
|
|
|
|
43 |
return quote(doi.strip()) if doi else None
|
44 |
|
45 |
def download_paper_scihub(self, doi):
|
@@ -219,7 +221,9 @@ class PaperDownloader:
|
|
219 |
pdf_content = self.download_with_retry(doi)
|
220 |
|
221 |
if pdf_content:
|
222 |
-
|
|
|
|
|
223 |
filepath = os.path.join(self.output_dir, filename)
|
224 |
with open(filepath, 'wb') as f:
|
225 |
f.write(pdf_content)
|
@@ -295,7 +299,9 @@ class PaperDownloader:
|
|
295 |
|
296 |
# Save PDF
|
297 |
if pdf_content:
|
298 |
-
|
|
|
|
|
299 |
filepath = os.path.join(self.output_dir, filename)
|
300 |
|
301 |
with open(filepath, 'wb') as f:
|
@@ -319,7 +325,7 @@ class PaperDownloader:
|
|
319 |
zipf.write(file_path, arcname=os.path.basename(file_path))
|
320 |
logger.info(f"ZIP file created: {zip_filename}")
|
321 |
|
322 |
-
return zip_filename, "\n".join(downloaded_files), "\n".join(failed_dois)
|
323 |
|
324 |
|
325 |
def create_gradio_interface():
|
@@ -379,7 +385,8 @@ def create_gradio_interface():
|
|
379 |
border-radius: 10px;
|
380 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
381 |
}
|
382 |
-
"""
|
|
|
383 |
)
|
384 |
|
385 |
return interface
|
|
|
40 |
|
41 |
def clean_doi(self, doi):
|
42 |
"""Clean and encode DOI for URL"""
|
43 |
+
if not isinstance(doi, str):
|
44 |
+
return None
|
45 |
return quote(doi.strip()) if doi else None
|
46 |
|
47 |
def download_paper_scihub(self, doi):
|
|
|
221 |
pdf_content = self.download_with_retry(doi)
|
222 |
|
223 |
if pdf_content:
|
224 |
+
if doi is None:
|
225 |
+
return None, "Error: DOI not provided", "Error: DOI not provided"
|
226 |
+
filename = f"{str(doi).replace('/', '_').replace('.', '_')}.pdf"
|
227 |
filepath = os.path.join(self.output_dir, filename)
|
228 |
with open(filepath, 'wb') as f:
|
229 |
f.write(pdf_content)
|
|
|
299 |
|
300 |
# Save PDF
|
301 |
if pdf_content:
|
302 |
+
if doi is None:
|
303 |
+
return None, "Error: DOI not provided", "Error: DOI not provided", None
|
304 |
+
filename = f"{str(doi).replace('/', '_').replace('.', '_')}.pdf"
|
305 |
filepath = os.path.join(self.output_dir, filename)
|
306 |
|
307 |
with open(filepath, 'wb') as f:
|
|
|
325 |
zipf.write(file_path, arcname=os.path.basename(file_path))
|
326 |
logger.info(f"ZIP file created: {zip_filename}")
|
327 |
|
328 |
+
return zip_filename, "\n".join(downloaded_files), "\n".join(failed_dois), None
|
329 |
|
330 |
|
331 |
def create_gradio_interface():
|
|
|
385 |
border-radius: 10px;
|
386 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
387 |
}
|
388 |
+
""",
|
389 |
+
cache_examples=False
|
390 |
)
|
391 |
|
392 |
return interface
|