davidedelpapa / gphotospy Goto Github PK
View Code? Open in Web Editor NEWUnofficial Google Photos Python library
License: MIT License
Unofficial Google Photos Python library
License: MIT License
when I try to stage more then 50 images, and then batchCreate, I get this:
Traceback (most recent call last):
File "/Users/alon/code/google_photos_uploader/uploader.py", line 114, in <module>
main()
File "/Users/alon/code/google_photos_uploader/uploader.py", line 110, in main
upload_albums(selected_dirs)
File "/Users/alon/code/google_photos_uploader/uploader.py", line 102, in upload_albums
media_manager.batchCreate(album_id=id_album)
File "/Users/alon/code/google_photos_uploader/google_photos_env/lib/python3.6/site-packages/gphotospy/media.py", line 697, in batchCreate
body=request_body).execute()
File "/Users/alon/code/google_photos_uploader/google_photos_env/lib/python3.6/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Users/alon/code/google_photos_uploader/google_photos_env/lib/python3.6/site-packages/googleapiclient/http.py", line 907, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://photoslibrary.googleapis.com/v1/mediaItems:batchCreate?alt=json returned "Request must have less than 50 items.">
it says here that more then 50 in each request is not allowed.
So maybe if len(self._staged_media) > 50
then it would split the request into a few pieces ?
(Im happy to fix it myself, let me know)
04:15 ~/mysite/wa $ python3 p2.py
Traceback (most recent call last):
File "p2.py", line 17, in
media_manager = Media(service)
File "/home/egmore/.local/lib/python3.8/site-packages/gphotospy/media.py", line 487, in init
self._service = service["service"]
TypeError: 'NoneType' object is not subscriptable
04:15 ~/mysite/wa $ cat gphtospy.log
root - 2021-05-22 04:15:36,098 - ERROR - argument should be integer or bytes-like object, not 'str'
I try to get all picture from a day with "search_iterator = media_manager.search(filter=[today])"
today = "2022-01-30"
And i get the error in the title.
Do you have some new about the field location with a media ?
Thanks awesome job.
Hello,
I am using more and more gphotospy and I am missing the option to search within an album.
That is: album.search(daterange)
for example.
Is the API capable of that and would you be willing to add this?
Regards,
Hendrik
Server issue?
https://bugs.python.org/issue25037
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.9/http/client.py", line 519, in _read_next_chunk_size
return int(line, 16)
ValueError: invalid literal for int() with base 16: b'T{E\xe9\x9d\xc6Wi\x99\xc1\xc0\xea+_\xcf\xef\xbb\xa5\xb2\x9f-\x87\x94\xb7\xe0\x14\x98\xe6\x8e\xeez\x18Y\xf1\xd9\xd1\x99\x7f\xe1v.\xe6\x87J\x81h*,\x84\xc8\x90S\xdc4\xaf\x03\xdbfEk|\xc8]G\x9c6\xaa\xf3\
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/fi2.py", line 248, in photos
photos_list=p2.photo_kudu().items()
File "/app/p2.py", line 27, in photo_kudu
for first_media in media_iterator:
File "/app/gphotospy/media.py", line 782, in list
result = self._service.mediaItems().list(
File "/app/.heroku/python/lib/python3.9/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/googleapiclient/http.py", line 920, in execute
resp, content = _retry_request(
File "/app/.heroku/python/lib/python3.9/site-packages/googleapiclient/http.py", line 191, in _retry_request
resp, content = http.request(uri, method, *args, **kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/google_auth_httplib2.py", line 218, in request
response, content = self.http.request(
File "/app/.heroku/python/lib/python3.9/site-packages/httplib2/__init__.py", line 1708, in request
(response, content) = self._request(
File "/app/.heroku/python/lib/python3.9/site-packages/httplib2/__init__.py", line 1424, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/app/.heroku/python/lib/python3.9/site-packages/httplib2/__init__.py", line 1405, in _conn_request
content = response.read()
File "/app/.heroku/python/lib/python3.9/http/client.py", line 462, in read
return self._readall_chunked()
File "/app/.heroku/python/lib/python3.9/http/client.py", line 569, in _readall_chunked
chunk_left = self._get_chunk_left()
File "/app/.heroku/python/lib/python3.9/http/client.py", line 552, in _get_chunk_left
chunk_left = self._read_next_chunk_size()
File "/app/.heroku/python/lib/python3.9/http/client.py", line 523, in _read_next_chunk_size
self._close_conn()
File "/app/.heroku/python/lib/python3.9/http/client.py", line 409, in _close_conn
fp.close()
AttributeError: 'NoneType' object has no attribute 'close'
return int(line, 16)
ValueError: invalid literal for int() with base 16: b'T{E\xe9\x9d\xc6Wi\x99\xc1\xc0\xea+_\xcf\xef\xbb\xa5\xb2\x9f-\x87\x94\xb7\xe0\x14\x98\xe6\x8e\xeez\x18Y\xf1\xd9\xd1\x99\x7f\xe1v.\xe6\x87J\x81h*,\x84\xc8\x90S\xdc4\xaf\x03\xdbfEk|\xc8]G\x9c6\xaa\xf3\
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/fi2.py", line 248, in photos
photos_list=p2.photo_kudu().items()
File "/app/p2.py", line 27, in photo_kudu
for first_media in media_iterator:
File "/app/gphotospy/media.py", line 782, in list
result = self._service.mediaItems().list(
File "/app/.heroku/python/lib/python3.9/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/googleapiclient/http.py", line 920, in execute
resp, content = _retry_request(
File "/app/.heroku/python/lib/python3.9/site-packages/googleapiclient/http.py", line 191, in _retry_request
resp, content = http.request(uri, method, *args, **kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/google_auth_httplib2.py", line 218, in request
response, content = self.http.request(
File "/app/.heroku/python/lib/python3.9/site-packages/httplib2/__init__.py", line 1708, in request
(response, content) = self._request(
File "/app/.heroku/python/lib/python3.9/site-packages/httplib2/__init__.py", line 1424, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/app/.heroku/python/lib/python3.9/site-packages/httplib2/__init__.py", line 1405, in _conn_request
content = response.read()
File "/app/.heroku/python/lib/python3.9/http/client.py", line 462, in read
return self._readall_chunked()
File "/app/.heroku/python/lib/python3.9/http/client.py", line 569, in _readall_chunked
chunk_left = self._get_chunk_left()
File "/app/.heroku/python/lib/python3.9/http/client.py", line 552, in _get_chunk_left
chunk_left = self._read_next_chunk_size()
File "/app/.heroku/python/lib/python3.9/http/client.py", line 523, in _read_next_chunk_size
self._close_conn()
File "/app/.heroku/python/lib/python3.9/http/client.py", line 409, in _close_conn
fp.close()
AttributeError: 'NoneType' object has no attribute 'close'
Hello,
thanks for gphotospy.
I am going to create a script, that downloads photos of my children for every week of their life. Then I am going to display them next to each other and create a slideshow to show how they developed.
For that, I manually did a search "John portrait" and created an album with the results.
But I wonder, if that search is also possible with gphotospy, followed by an iteration over the results?
Best regards,
Hendrik
I get the following error:
`TypeError Traceback (most recent call last)
in
10 print(service)
11 # Init the album manager
---> 12 album_manager = Album(service)
13
14 # Create a new album
~/jupyter/lib/python3.7/site-packages/gphotospy/album.py in init(self, service)
170 """
171
--> 172 self._service = service["service"]
173 self._secrets = service["secrets"]
174
TypeError: 'NoneType' object is not subscriptable`
Hello! Thanks for gphotospy.
Please add example for download all album and all photo from google photo to local.
Thanks!
going through the auth flow and am getting the following error:
Traceback (most recent call last):
File "/home/kjnether/proj/googlephoto/src/authorize.py", line 30, in <module>
service = authorize.init(constants.CLIENT_SECRET_FILE)
File "/home/kjnether/.local/share/virtualenvs/googlephoto-H2bFJvmL/lib/python3.8/site-packages/gphotospy/authorize.py", line 55, in init
credentials = get_credentials(secrets)
File "/home/kjnether/.local/share/virtualenvs/googlephoto-H2bFJvmL/lib/python3.8/site-packages/gphotospy/authorize.py", line 34, in get_credentials
credentials = app_flow.run_local_server()
File "/home/kjnether/.local/share/virtualenvs/googlephoto-H2bFJvmL/lib/python3.8/site-packages/google_auth_oauthlib/flow.py", line 457, in run_local_server
local_server = wsgiref.simple_server.make_server(
File "/usr/lib/python3.8/wsgiref/simple_server.py", line 154, in make_server
server = server_class((host, port), handler_class)
File "/usr/lib/python3.8/socketserver.py", line 452, in __init__
self.server_bind()
File "/usr/lib/python3.8/wsgiref/simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python3.8/http/server.py", line 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.8/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
Not sure what is using the default port on my machine. Either way to get around it wanted to use custom port for the authorization. Resolved the issue by modifying this line to
if 'GPHOTOSPY_AUTH_PORT' in os.environ:
credentials = app_flow.run_local_server(os.environ['GPHOTOSPY_AUTH_PORT'])
else:
credentials = app_flow.run_local_server()
Are there any functions to remove one or multiple albums?
Is it possible to build a photo/video duplicate finder? I have some photos that appear more than once but it's quite painful to manually scroll through thousands of pics.
Thoughts:
If we don't feel that this would be a good library example, no worries. In that case just looking for thoughts. Thanks!
Please provide documentation on how to download an image, and even better, create a function that can download an image from Google Photos to a specific local folder, preserving the original date of the image (i.e. the date of the file should be the original photo date), its full resolution (no cropping or resizing), and as much as possible of the original metadata (I think only the location is unavailable in Google photos).
The iterator that returns search results is neverending. It just keeps looping through the same set of files continuously.
I'm trying to use the raw_download() function to download the original media file for a photo or video. But in all cases I get much smaller files than the originals.
For example, a video file shows like this in Google photos:
After downloading, my local version is 6.6 MB
That's 6.6 instead of 188,9 MB.
As I'm looking for a way to archive my original files, I'd be happy for a hint. Cheers and merry christmas!
Hi - I had all this working fine and was just making final tweaks to a program that would, every month, re-populate a "Month In History" folder with a random selection of pictures from that month, for use in my Chromecast With Google TV screensaver, but then I got
raise exceptions.RefreshError(
google.auth.exceptions.RefreshError: ('invalid_grant: Token has been expired or revoked.', {'error': 'invalid_grant', 'error_description': 'Token has been expired or revoked.'})
I have recreated all the steps in the google Dev site for the token file, but without any luck
Thoughts?
Cheers
Hi,
I want to add a feature of making the requests to google async, since its very slow to upload one by one when you have a lot of images to upload.
(I still need to test whether the slowness comes from the API or is it CPU bound slowness).
But would that fit this package?
so maybe an API like this:
media_manager.bulk_stage_media(["/path/to/photo1.png", "/path/to/photo2.jpg"])
media_manager.batchCreate()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.