amazon_photos
amazon_photos copied to clipboard
Unable to create an AmazonPhoto instance
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/[email protected]/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/[email protected]/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
I had the same issue, from your Github profile you are based in the UK, the mappings _constants.py maps to uk and it should .co.uk. Therefore the url it calls is amazon.uk instead of .co.uk https://github.com/trevorhobenshield/amazon_photos/blob/685c965b5a4ba1ac85d418820ad200e12c18a46d/amazon_photos/_constants.py#L111
To fix it, I hardcoded self.drive_url = f'https://www.amazon.co.uk/drive/v1'
Would need a PR to fix it for the uk domain properly
I had the same issue, from your Github profile you are based in the UK, the mappings _constants.py maps to uk and it should .co.uk. Therefore the url it calls is amazon.uk instead of .co.uk
https://github.com/trevorhobenshield/amazon_photos/blob/685c965b5a4ba1ac85d418820ad200e12c18a46d/amazon_photos/_constants.py#L111
To fix it, I hardcoded
self.drive_url = f'https://www.amazon.co.uk/drive/v1'
Would need a PR to fix it for the uk domain properly
This worked - I hard-coded that url as well and it has stopped giving me this error. Though now I'm getting the error Cookies expired
. I experimented with different cookies on different machines yet still had the same result which perplexed me, as the expiry date is said to be next year in chrome. May I ask if you've got the same error? Thanks in advance!
The only other error I encountered was #16 and once I made the fix from the PR it worked for me.