trevorhobenshield / amazon_photos

Amazon Photos API
https://pypi.org/project/amazon_photos
MIT License
44 stars 6 forks source link

Unable to create an AmazonPhoto instance #12

Open nh8157 opened 3 months ago

nh8157 commented 3 months ago

I copied the sample code from the readme file, which connects the app to my Amazon Photo, then gets AP's status.

from amazon_photos import AmazonPhotos

ap = AmazonPhotos(
    # see cookie examples above
    cookies={
        'ubid_acbuk': "2-xxx-8",
        'at_acbuk': "A-xxx-w",
        'session-id': "2-xxx-1",
    },
    # optionally cache all intermediate JSON responses
    tmp='tmp',
    # pandas options
    dtype_backend='pyarrow',
    engine='pyarrow',
)

# get current usage stats
ap.usage()

The program hangs when I run it, though I have received SMS/emails from Amazon informing me of a new login. When I exit the program using Ctrl+C, it spills out the following stack trace.

Traceback (most recent call last):
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
    yield
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpx/_transports/default.py", line 233, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
    raise exc from None
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 196, in handle_request
    response = connection.handle_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 99, in handle_request
    raise exc
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 76, in handle_request
    stream = self._connect(request)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 122, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpcore/_backends/sync.py", line 205, in connect_tcp
    with map_exceptions(exc_map):
  File "/usr/local/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [Errno 8] nodename nor servname provided, or not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/amazon_photos/_api.py", line 157, in backoff
    r = fn(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpx/_client.py", line 1054, in get
    return self.request(
           ^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpx/_client.py", line 827, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpx/_client.py", line 914, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpx/_client.py", line 942, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpx/_client.py", line 979, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpx/_client.py", line 1015, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpx/_transports/default.py", line 232, in handle_request
    with map_httpcore_exceptions():
  File "/usr/local/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sheldonchen/Projects/amazon-photos-sync/scanner.py", line 3, in <module>
    ap = AmazonPhotos(
         ^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/amazon_photos/_api.py", line 77, in __init__
    self.root = self.get_root()
                ^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/amazon_photos/_api.py", line 907, in get_root
    r = self.backoff(self.client.get, f'{self.drive_url}/nodes', params={'filters': 'isRoot:true'} | self.base_params)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sheldonchen/Projects/amazon-photos-sync/lib/python3.12/site-packages/amazon_photos/_api.py", line 188, in backoff
    time.sleep(t)
KeyboardInterrupt