Code Monkey home page Code Monkey logo

gphotospy's People

Contributors

akleiw avatar alon-claroty avatar davidedelpapa avatar funblaster22 avatar kosmas10 avatar paleg avatar smartmanoj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gphotospy's Issues

Request must have less than 50 items exception when trying to upload more then 50 images

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)

service is None

#12

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'

search in albump

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

AttributeError: 'NoneType' object has no attribute 'close'

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'

"Search" instead of Filter

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

service is None

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`

Authorize: errors with Address already in use

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()

Duplicate Finder

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:

  • Can we use image metadata to find potential duplicates? Maybe same location, timestamp, size means possible duplicate?
  • Maybe we read all metadata local then find duplicates to only bulk hit the API once (or in one loop at the start)?
  • I'd love to avoid downloading each media to check, since I'm already too close to my Comcast data cap :P

If we don't feel that this would be a good library example, no worries. In that case just looking for thoughts. Thanks!

Add code/documentation for downloading images

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).

raw_download() only delivers reduced size video files

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:

grafik

After downloading, my local version is 6.6 MB

grafik

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!

Token expired

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

async requests

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()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.