The little things give you away... A collection of various small helper stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

28 lines
869 B

  1. #!/usr/bin/env python3
  2. # External dependency: requests
  3. import getpass
  4. import requests
  5. import shlex
  6. import sys
  7. if len(sys.argv) < 2:
  8. email = input('E-mail address: ')
  9. elif sys.argv[1] in ('--help', '-h') or len(sys.argv) > 2:
  10. print('Usage: ia-s3-auth [EMAIL]', file = sys.stderr)
  11. sys.exit(1)
  12. else:
  13. email = sys.argv[1]
  14. password = getpass.getpass()
  15. r = requests.post('https://archive.org/services/xauthn/?op=login', data = {'email': email, 'password': password}, headers = {'User-Agent': 'little-things +https://gitea.arpa.li/JustAnotherArchivist/little-things'}, timeout = 30)
  16. o = r.json()
  17. if not o.get('success'):
  18. error = o.get('values', {}).get('reason') or o['error']
  19. print(f'Error: {error}', file = sys.stderr)
  20. sys.exit(2)
  21. print(f'IA_S3_ACCESS={shlex.quote(o["values"]["s3"]["access"])}')
  22. print(f'IA_S3_SECRET={shlex.quote(o["values"]["s3"]["secret"])}')