C2MV commited on
Commit
2915123
1 Parent(s): 59efd33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -248,12 +248,17 @@ class PaperDownloader:
248
 
249
  downloaded_files = []
250
  failed_dois = []
251
- for doi in tqdm(dois, desc="Downloading papers"):
252
- filepath, success_message, fail_message = self.download_single_doi(doi)
253
- if filepath:
254
- downloaded_files.append(filepath)
255
- else:
256
- failed_dois.append(doi)
 
 
 
 
 
257
 
258
  if downloaded_files:
259
  zip_filename = 'papers.zip'
@@ -338,7 +343,7 @@ def create_gradio_interface():
338
  if not bib_file.name.lower().endswith('.bib'):
339
  return None, "Error: Please upload a .bib file", "Error: Please upload a .bib file", None
340
 
341
- zip_path, downloaded_dois, failed_dois = downloader.process_bibtex(bib_file)
342
  return zip_path, downloaded_dois, failed_dois, None
343
  elif doi_input:
344
  filepath, message, failed_doi = downloader.download_single_doi(doi_input)
@@ -386,7 +391,7 @@ def create_gradio_interface():
386
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
387
  }
388
  """,
389
- cache_examples=False
390
  )
391
 
392
  return interface
 
248
 
249
  downloaded_files = []
250
  failed_dois = []
251
+ for i, doi in enumerate(tqdm(dois, desc="Downloading papers")):
252
+ filepath, success_message, fail_message = self.download_single_doi(doi)
253
+ if filepath:
254
+ # Unique filename for zip
255
+ filename = f"{str(doi).replace('/', '_').replace('.', '_')}_{i}.pdf"
256
+ filepath_unique = os.path.join(self.output_dir, filename)
257
+ os.rename(filepath,filepath_unique)
258
+ downloaded_files.append(filepath_unique)
259
+ else:
260
+ failed_dois.append(doi)
261
+
262
 
263
  if downloaded_files:
264
  zip_filename = 'papers.zip'
 
343
  if not bib_file.name.lower().endswith('.bib'):
344
  return None, "Error: Please upload a .bib file", "Error: Please upload a .bib file", None
345
 
346
+ zip_path, downloaded_dois, failed_dois, _ = downloader.process_bibtex(bib_file)
347
  return zip_path, downloaded_dois, failed_dois, None
348
  elif doi_input:
349
  filepath, message, failed_doi = downloader.download_single_doi(doi_input)
 
391
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
392
  }
393
  """,
394
+ cache_examples = False
395
  )
396
 
397
  return interface