ferru97 / PyPaperBot

PyPaperBot is a Python tool for downloading scientific papers using Google Scholar, Crossref, SciHub, and SciDB.
MIT License
409 stars 77 forks source link

Download error. TypeError. #20

Closed kir-malishev closed 3 years ago

kir-malishev commented 3 years ago

Hello!

I got this error while downloading

Download 202 of 8701 -> None
Traceback (most recent call last):
  File "C:\Users\kir-m\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\kir-m\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\kir-m\AppData\Local\Programs\Python\Python37\lib\site-packages\PyPaperBot\__main__.py", line 122, in <module>
    main()
  File "C:\Users\kir-m\AppData\Local\Programs\Python\Python37\lib\site-packages\PyPaperBot\__main__.py", line 118, in main
    start(args.query, args.scholar_pages, dwn_dir, args.min_year , max_dwn, max_dwn_type , args.journal_filter, args.restrict, DOIs)
  File "C:\Users\kir-m\AppData\Local\Programs\Python\Python37\lib\site-packages\PyPaperBot\__main__.py", line 45, in start
    downloadPapers(to_download, dwn_dir, num_limit)
  File "C:\Users\kir-m\AppData\Local\Programs\Python\Python37\lib\site-packages\PyPaperBot\Downloader.py", line 62, in downloadPapers
    pdf_dir = getSaveDir(dwnl_dir, p.getFileName())
  File "C:\Users\kir-m\AppData\Local\Programs\Python\Python37\lib\site-packages\PyPaperBot\Paper.py", line 31, in getFileName
    return re.sub('[^\w\-_\. ]', '_', self.title)+".pdf"
  File "C:\Users\kir-m\AppData\Local\Programs\Python\Python37\lib\re.py", line 192, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object

I understand that all download problems are difficult to fix. But I need to download quite a few articles. I would like to have, for example, an option or default behavior when such errors do not lead to an abnormal end but are written to the log. I think it's easy to do it by adding try-except.

ferru97 commented 3 years ago

Ok yes in the day I add that control

ferru97 commented 3 years ago

Solved