akamhy / waybackpy

Wayback Machine API interface & a command-line tool
https://pypi.org/project/waybackpy/
MIT License
462 stars 34 forks source link

cli.py (near,archive,oldest,newset) : Output a nice message and tell the user that the page isn't archived #50

Closed akamhy closed 3 years ago

akamhy commented 3 years ago

Problem : https://github.com/akamhy/foo-bar-is-real is 404. I am requesting an archive for an URL that doesn't exist and therefore ain't archived on wayback machine.

The following text is not helpful to folks who don't know python. And looks unprofessional from CLI point of view.

$ waybackpy --oldest --url https://github.com/akamhy/foo-bar-is-real
Traceback (most recent call last):
  File "/home/akamhy/anaconda3/bin/waybackpy", line 8, in <module>
    sys.exit(main())
  File "/home/akamhy/.local/lib/python3.8/site-packages/waybackpy/cli.py", line 254, in main
    output = args_handler(args)
  File "/home/akamhy/.local/lib/python3.8/site-packages/waybackpy/cli.py", line 138, in args_handler
    return _oldest(obj)
  File "/home/akamhy/.local/lib/python3.8/site-packages/waybackpy/cli.py", line 25, in _oldest
    return obj.oldest()
  File "/home/akamhy/.local/lib/python3.8/site-packages/waybackpy/wrapper.py", line 202, in oldest
    return self.near(year=year)
  File "/home/akamhy/.local/lib/python3.8/site-packages/waybackpy/wrapper.py", line 184, in near
    raise WaybackError(
waybackpy.exceptions.WaybackError: Can not find archive for 'https://github.com/akamhy/foo-bar-is-real' try later or use wayback.Url(url, user_agent).save() to create a new archive.
akamhy commented 3 years ago

Fixed in v2.3.2