DEV Community

Discussion on: Manage your Google Photo account with Python! (p.1)

Collapse
 
clanmills profile image
Robin Mills • Edited

Wow. Great Work. Your code worked first time for me and showed me a photo from my Google Photo Library that I took on Thursday.

Now, I'm going to read your code and discover how you did that. Amazing.

I'm the retired maintainer of Exiv2 the C++ Metadata Library. exiv2.org

I'm rebuilding my web-site from scratch because it's 20 years old, has 80,000 photos in 2000 albums, 400,000 files and occupies 10GB on the web-server. I'm going to store the photos on Google Photos and generate the photo albums in JavaScript. I've made good progress and confident that the web-site will be less than 100mb by the end of September. Here's a typical album web-page: clanmills.com/2021/Lizzie

The code for the page is:

505 rmills@rmillsm1:~/clanmills $ cat 2021/Lizzie/default.shtml 
<!--#include virtual="/albumhead.inc" -->
<!--#include virtual="/menu.inc" -->
<!--#include virtual="/albumtail.inc" -->
<script type="text/javascript">
   var title   = "Lizzie"
   var data    = 'https://photos.app.goo.gl/sQRaVMZiyTr5T74y8'
   var updated = '2021-08-20 14:52:25'
   buildPage();
</script>
506 rmills@rmillsm1:~/clanmills $ 
Enter fullscreen mode Exit fullscreen mode

The next job is to understand enough Python/REST/Photos magic to generate the list of album files automatically. The script will run once a day at home and update clanmills.com. So, when I take photos with my phone, they be posted on clanmills.com without moving a finger.

Thanks to your python code, I'm confident of success. Thank You Very Much.

Collapse
 
davidedelpapa profile image
Davide Del Papa

You are welcome. I made the lib to script access to my wedding pics myself, so I guess your use case should be not too difficult to tackle as well.
Good luck 🤞

Collapse
 
clanmills profile image
Robin Mills

Davide: I love your code. It's beautiful and clear.

I fixed a tiny bug in album.py. When I iterate the albums (I have 250 albums) the loop dies at the end saying "object isn't interable:"

    'title': 'BoysInSanJose2002'}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/3.8/site-packages/gphotospy/album.py", line 533, in list
    for album in curr_list:
TypeError: 'NoneType' object is not iterable
Enter fullscreen mode Exit fullscreen mode

Here's my fix:

0a1
> from collections.abc import Iterable
533,534c534,536
<             for album in curr_list:
<                 yield album
---
>             if isinstance(curr_list, Iterable):
>                 for album in curr_list:
>                     yield album
Enter fullscreen mode Exit fullscreen mode

Question. Is the code in GitHub. Can I provide a PR if I find other issues?