Links for June 2022

Updated on Thursday, June 23, 2022

How to backup Google Photos to Google Drive automatically after July 2019 with Apps Script

Updated on Saturday, September 3, 2022

Warning - I no longer recommend using this script to backup Google Photos. The Google Photos API has too many bugs that Google doensn't seem interested in fixing. My personal approach at this point is to use Google Takeout to get a periodic archive of my most recent year of photos and videos. I have a tool that does some deduplication and puts everything in year/month folders. See Photo Sorter for more details.

Google Photos backup to Google Drive shutting down in July 2019

Google has decided that backing up your photos via Google Drive is 'confusing' and so Drive based backup is going away this month. I love Google Photos but I don't trust it - I pull everything into Drive and then I stick a monthly backup from there onto an external drive in a fire safe. There is a way to get Drive backup working again using Google Apps Script and the Google Photos API. There are a few steps to follow but it's pretty straightforward - you should only need to change two lines in the script to get this working for your account.

First two four caveats to be aware of. Apps Script has a time limit and so it's possible that it could fail if moving a large number of photos. You should get an email if the script ever fails so watch out for that. Secondly and more seriously you could end up with two copies of your photos. If you use Backup and Sync to add photos from Google Drive then these photos will be downloaded from Google Photos by the script and added to Drive again. You need to either upload directly to Google Photos (i.e. from the mobile app or web site) or handle the duplicates in some way. If you run Windows then I have released a command line tool that sorts photos into year+month taken folders and handles de-duplication.

One more limitation. After a comment by 'Logan' below I realized that Apps Script has a 50MB limitation for adding files to Google Drive. The latest version of the script will detect this and send you an email listing any files that could not be copied automatically.

And a fourth limitation after investigating a comment by 'Tim' it turns out there is a bug in the Google Photos API that means it will not download original quality video files. You get some lower resolution version instead. Together with the file size limit this is a bit of a deal breaker for most videos. Photos will be fine, but videos will need a different fix.

On to the script. In Google Drive create a new spreadsheet. This is just a host for the script and makes it easy to authorize it to access Google Photos. Select 'Script editor' from the Tools menu to create a new Apps Script project.

In the script editor select 'Libraries...' from the Resources menu. Enter 1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF next to 'Add a library' and click add. This will find the Google OAuth2 library Pick the most recent version and click Save.

Select 'Project properties' from the File menu and copy the Script ID (a long sequence of letters and numbers). You'll need this when configuring the Google Photos API.

In a new window open the Google API Console, part of the Google Cloud Platform. Create a new project, click Enable APIs and Services and find and enable the Google Photos API. Then go to the Keys section and create an OAuth Client ID. You'll need to add a consent screen, the only field you need to fill out is the product name. Choose Web Application as the application type. When prompted for the authorized redirect URL enter https://script.google.com/macros/d/{SCRIPTID}/usercallback and replace {SCRIPTID} with the Script ID you copied above. Copy the Client ID and Client Secret which will be used in the next step.

Go back to the Apps Script project and paste the code below into the Code.gs window:

Enter the Client ID and Client Secret inside the empty quotes at the top of the file. You also need to add an email address to receive alerts for large files. There is a BackupFolder option at the top as well - the default is 'Google Photos' which will mimic the old behavior. You can change this if you like but make sure that the desired folder exists before running the script. Save the script.

Go back to the spreadsheet you created and reload. After a few seconds you will have a Google Photos Backup menu (to the right of the Help menu). Choose 'Authorize' from this menu. You will be prompted to give the script various permissions which you should grant. After this a sidebar should appear on the spreadsheet (if not choose 'Authorize' from the Google Photos Backup menu again). Click the authorize link from the sidebar to grant access to Google Photos. Once this is done you should be in business - choose Backup Now from the Google Photos Backup menu and any new items from yesterday should be copied to the Google Photos folder in Drive (or the folder you configured above if you changed this).

Finally you should set up a trigger to automate running the script every day. Choose 'Script editor' from the Tools menu to re-open the script, and then in the script window choose 'Current project's triggers' from the Edit menu. This will open yet another window. Click 'Add Trigger' which is cunningly hidden at the bottom right of the window. Under 'Choose which function to run' select 'runBackup'. Then under 'Select event source' select 'Time-driven'. Under 'Select type of time based trigger' select 'Day timer'. Under 'Select time of day' select the time window that works best for you. Click Save. The backup should now run every day.

The way the script is written you'll get a backup of anything added the previous day each time it runs. If there are any duplicate filenames in the backup folder the script will save a new copy of the file with (1) appended in front of the filename. Let me know in the comments if you use this script or have any suggestions to improve it.

Add your comment...

More Google Apps Script Projects

(All Code Posts)

(Published to the Fediverse as: How to backup Google Photos to Google Drive automatically after July 2019 with Apps Script #code #software #photos #appsscript #google #sheets #drive #api Easy to configure apps script to continue backing up your Google Photos to Google Drive after the July 2019 change. You just need to change two lines of the script to get this running with your Google Photos account. )

Google Spreadsheets API and Column Names

Updated on Sunday, May 2, 2021

Google Spreadsheets API and Column Names

I had a play with the Google Spreadsheets API recently to feed in some data from a C# application. The getting started guide is great and I was authenticated and adding dummy data in no time. But as soon as I started to work with real data I got:

"The remote server returned an error: (400) Bad Request."

And digging deeper into the response:

"We're sorry, a server error occurred. Please wait a bit and try reloading your spreadsheet."

The original sample code still worked so it didn't seem like any sort of temporary glitch as the message suggests. After much hair torn it turns out I was getting this error because I had used the literal column names from my spreadsheet. The API expects them to be lower case with spaces removed. If not columns match you get the unhelpful error above, if at least one column matches you get a successful insert with some missing data.

Error messages are one of the hardest parts of an API to get right. If you're not very detailed then what seems obvious to you can leave your developers stumped.

Hope this helps someone else...

Add your comment...

Related Posts

You Might Also Like

(All Etc Posts)

(Published to the Fediverse as: Google Spreadsheets API and Column Names #etc #google #api #spreadsheet A 400 bad request from the Google Spreadsheets API may be caused by incorrect column names. How to fix. )

Twitter's API has got too painful for me

Updated on Thursday, November 12, 2015

Twitter's API has got too painful for me

I've developed a bunch of stupid, niche and vaguely promising apps on top of the Twitter API. During that time I've slogged through various painful and rapid shifts like changing IDs, authentication schemes and diktats handed down on which parts of the ecosystem Twitter would like to control. I've had to roll my own OAuth and even re-word a blog post to Twitter Support's satisfaction to get a blocked application unblocked again. It's been a pretty frustrating experience but worth rolling with the punches until the past week.

Twitter suspended Cleat, a tool for posting from the command line. So I emailed to ask why, too much effort for them to explain the rationale at the time they're putting the suspension in place I guess. I got an auto-response asking for information they must have already had and I replied to this. A few days later I still hadn't heard back so I emailed again and the ticket had been automatically closed. 

So far just the standard fuck-off-and-die support that you'd expect from a growing company that no longer wants to talk to it's users. But the auto-reply directed me to https://support.twitter.com/forms/ to file a new ticket. None of the options there relate to developers or a suspended application. I tried filing a ticket under 'deactivated account' which seemed the closest.

That form has a hard-coded 'With love,' valediction. Whoever thought that was cute should go through the process of trying to get help a few times. 

This attempt auto-responded to say that my account was not suspended, and would I like to fuck-off-and-die or got back to the forms center?

So I tried another form that actually seemed to submit but haven't heard anything back.

I'd be happy to update my software if I know which vague shifting facet of the Twitter terms of use I'd fallen foul of. Or at least I would have been. I'm just so sick of it that I've pulled Cleat and I'm done with any more personal projects that use the Twitter API. 

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

(Published to the Fediverse as: Twitter's API has got too painful for me #code #twitter #cleat #commandline #api Twitter's opaque API policies have led to me no longer developing on the platform. )

Reviews and Links for February 2012

Updated on Friday, May 22, 2020

The Snowman by Jo Nesbø

4/5

Very good, enjoying the entire Harry Hole series. Wishing for translations of the first two now!

 

The Devil's Star by Jo Nesbø

3/5

Slightly weaker than the others in the series I've read so far but still knocked it back quickly.

 

The Redbreast by Jo Nesbø

4/5

Best so far on my quest to read through Nesbo...

 

Nemesis by Jo Nesbø

4/5

On a Jo Nesbo binge...

 

The Leopard by Jo Nesbø

4/5

Compelling crime thriller, rather worryingly one of series featuring Harry Hole so I'm going to have to go back to the beginning and read all of them.

 

Links

Catfood.Shapefile 1.51: http://t.co/BKtkx9Zq (ESRI Shapefile Parser, fixed release binary issue).

4 of 5 stars to The Snowman by Jo Nesbø http://t.co/IrvdrDBf

Breaking Good: how to synthesize Pseudoephedrine (Sudafed) From N-Methylamphetamine (crystal meth): http://t.co/fviYaj5P

ITHCWY: Catfood.Shapefile 1.50: I've just released a small update to my C# Shapefile library on Codeplex. Catfood… http://t.co/lXoGoBsY

4 of 5 stars to The Redbreast by Jo Nesbø http://t.co/PqrOQnQL

Epic #Bernal Panorama: http://t.co/zVqZYosG - via @bernalwood

Neal Stephenson on getting big stuff done http://t.co/6PHS1VD1 #todo @myEN

Stop Colbert: http://t.co/kBtSC7NV via @NancyPelosi

Wolfram|Alpha Pro: http://t.co/G88eWq6Y #tools @myEN

A History of the Sky for One Year: http://t.co/UKMjosCK (very cool)

+1: A U.S. appeals court rules Prop. 8 unconstitutional: http://t.co/TZgdKU9k #fb

ITHCWY: Badge Driven Development: Microsoft has released Visual Studio Achievements, an extension that brings… http://t.co/5BOyNF03

ITHCWY: GGNRA Dog Management Plan Update: I love it when making some noise works. The NPS is pushing its dog… http://t.co/fzqaJWM2

Unicode Character 'PILE OF POO' (U+1F4A9): http://t.co/LkGffsvW

http://t.co/NA6TOdQk #todo @myEN

BBC News - Can the US Army embrace atheists? http://t.co/5ubkKT7r

Running an API at HUGE Scale - Webinar: http://t.co/tEnxdRBM #API

4 of 5 stars to The Leopard by Jo Nesbø http://t.co/tIIPs1M5

ITHCWY: Reviews and Links for January 2012: Damned by Chuck Palahniuk 3/5 Very much a vehicle for Palahniuk to rant… http://t.co/6kvApyf1

Add your comment...

Related Posts

You Might Also Like

(All Etc Posts)

Reviews and Links for January 2012

Updated on Thursday, November 12, 2015
Damned by Chuck Palahniuk

Damned by Chuck Palahniuk

3/5

Very much a vehicle for Palahniuk to rant about this and that through the voice of a 13 year old girl condemned to hell, supposedly for overdosing on pot. Entertaining, but felt that the plot served the ranting rather than the other way round.

 

Links

Shit Programmers Say: http://t.co/0rYyXWM5

Best explanation of software estimation failure ever: http://t.co/jC5hmQ3g

I've just funded Mission:Explore Food on Pleasefund.Us: http://t.co/ysLyDOZ6

Another comedy amendment: http://t.co/sWAqflbO

Shit Bernalites Say: http://t.co/O8AY0sgs from @bernalwood

San Francisco's rubbish - why everyone wants a share: http://t.co/kHzC6mgf

Own a color: http://t.co/5jKpfvJO (for Unicef)

Just say terrorist enough times Panetta: http://t.co/07tmXDEO

Applause: VA state senator attaches rectal exam amendment tacked on to anti-abortion bill http://t.co/Neezj7n6

ITHCWY: Has France Cracked Fixing Education?: The French are close to making it illegal to deny a second genocide… http://t.co/koOkE02M

Arrrrgggghhhh, it's pledge. Go throw @KQED a bone radio-chavving-freeloaders: http://t.co/ur7fBVGx

ITHCWY: But does it get you in the HOV lane?: Interesting but highly disturbing alternative fuel source... http://t.co/IOUVbIPD

Shit San Franciscans Say: http://t.co/vVfiI5yJ via @youtube

IANAL, but it certainly seems a bit crazy: http://t.co/iVW4I4ZR

Discover London With Mission:Explore! http://t.co/T0ZVGGr4

Load Testing with @CloudAssault http://t.co/PkwYNOh1 #API @myEN

Shit Silicon Valley Says: http://t.co/YK1Hlbws via @youtube

On the subject of deadly pork, MRSA found on 7% of samples in a University of Iowa test: http://t.co/1wIK1uqE

Thanks SCOTUS for making us eat sick pigs: http://t.co/scTowXXI

+1: http://t.co/V7QW1hi0 "I sent you a truck, a boat, and a helicopter! What the hell more did you want from me?"

Yay! Precita Park Upgrade: http://t.co/f4JOcNS7

Mission:Explore Food - PleaseFund.Us http://t.co/ysLyDOZ6 via @pleasefundus

ITHCWY: Mission:Explore Food - Crowd Fund It!: My brother is part of the Geography Collective, the team that make… http://t.co/jg6s9FKK

The word 'sustainable' is unsustainable: http://t.co/Iw8e9P2Q (XKCD)

Next step, jail for incorrect maths answers: http://t.co/US35YW2v (more illegal history in France...)

Chilling Effects: http://t.co/dXUSwGOQ (post Megaupload, file sharing sites disabling sharing)

http://t.co/jU4AeOdh

Visual Studio Gamification: http://t.co/kgHvGtsi

Shut down the Interstate highway system because a few people are speeding? Then don't do this: http://t.co/gvSaucwu

My new favorite word: semithermonuclear: http://t.co/zV8u067w (what Google will be doing tomorrow).

3 of 5 stars to Damned by Chuck Palahniuk http://t.co/CcmlNPqL

ITHCWY: Carr is Wrong: Costolo is Wrong: Wikipedia’s SOPA Blackout is a Great Idea: I was very happy to see… http://t.co/6rlFNgut

ITHCWY: Yet more on breaking the Internet: January 18th is Internet blackout day to protest against SOPA and PIPA… http://t.co/RH5bhObW

Web Goes On Strike: Jan 18th! All-out blackout 2 stop #SOPA #PIPA. Petition @twitter and other sites to join us. http://t.co/UNird4iF

ITHCWY: Better Paperless: I've just spent several hours scanning and then shredding tedious statements, medical… http://t.co/J7GBWJsb

ITHCWY: Misplaced Outrage: The video of US Marines urinating on corpses is shocking and counterproductive. But it's… http://t.co/E4jWRVcI

Worked on this idea in 2004, didn't get funded: http://t.co/CFuCTblk (Cloud-Based Video Editor WeVideo Launches To Public)

ITHCWY: Farallon Islands: A rare clear day where you can see the Farallon Islands from Fort Funston. http://t.co/hkvR1zYp

http://t.co/lPfzZesz

ITHCWY: More on breaking the Internet: I finally got round to actually reading SOPA and PIPA. I make my living from… http://t.co/WW8wIKou

Stop Internet #Censorship! Sign the global petition @Avaaz urging the US Congress to reject the #Blacklist Bill #SOPA http://t.co/MfsrnrBy

Illegal dumping on Bernal Hill: http://t.co/lR4GemC0 - Vote to get this cleaned up!

Office dog... #fb http://t.co/aOlinLwD

A Bird’s Eye View of Bernal Heights in 1938: http://t.co/XluPCJjW from @Bernalwood

AT&T LTE lights up in San Francisco: http://t.co/CzlJuUYo

ITHCWY: Installation: Early and Often: Jiri Novotny at Dextronet wrote a great post this week on improving… http://t.co/Q1rvrAWm

ITHCWY: Moon on a Wire: Testing posting by email with a picture of the moon from last night... I've extended… http://t.co/MQvLSeBj

William Gibson Essays: http://t.co/9AD9jQmo (How much do I need a parallel universe reading day?)

ITHCWY: LEGO, now for Girls: LEGO Friends is “The new LEGO theme – for girls!” So I guess the current sets not for… http://t.co/yVtN7awL

The Commodore 64 is 30 http://t.co/bBslFoVF via @reghardware

ITHCWY: Catfood.Shapefile 1.40: I’ve just released a small update to Catfood.Shapefile. Stephan Stapel, who… http://t.co/qindsQBw

Looking forward to seeing the restored Battery Townsley: http://t.co/jDPvI3jU #todo @myEN

Is Obama doomed in 2012? http://t.co/aGKoq2Nw

Add your comment...

Related Posts

You Might Also Like

(All Reviews)

Reviews and Links for November 2011

Updated on Friday, February 24, 2017

Reamde by Neal Stephenson

5/5

Intelligent and humorous if highly contrived thriller set loosely around an MMORPG. Loved it.

 

Embassytown by China Miéville

4/5

Highly original tale of colonists cohabiting with some very unusual aliens with a very unusual language. It reads like J.G. Ballard and Nicholson Baker decided to collaborate on some SciFi.

 

The Affair (Jack Reacher, #16) by Lee Child

3/5

Not bad, returns to when Reacher was in uniform and tells the story of how he left the Army (the answer may surprise you). As with the last few in the series it all comes a little too easily and you wish there was at least one worthy opponent. I'm hooked though so as long as Child keeps writing them I'll keep reading.

 

Professional Android 2 Application Development by Reto Meier

3/5

Solid foundation and covers the platform you need to target to reach the majority of Android devices.

 

Links

RE: Feel free to use the code, no attribution required.  http://t.co/IJTcOz3p

BBC News - 7 questions on computer programmes http://t.co/XKylU7WT (more of a history / pop culture quiz)

Scooby-Doo and Secular Humanism: http://t.co/4h8M8kkK

4 of 5 stars to Embassytown by China Miéville http://t.co/kPwIrmDF

ITHCWY: Occupy Intellectual Ventures: Send them a troll. Now. http://t.co/VorWmZpz

Wow, My Flout score is -7 on @floutdotme! Get yours at http://t.co/1Sl8ei72

troll the troll! send a troll doll to intellectual ventures. http://t.co/S09ML14T via @nathtone

Walking through doorways causes forgetting, new research shows: http://t.co/JBbJXAaD

+1: Why Software Projects are Terrible and How Not To Fix Them: http://t.co/kE7WWix5

Hilarious, I had to Google how to power off Windows 8. Didn't figure it our until the third link: http://t.co/X1wrkh7R #fail

Building a Useful Task Board: http://t.co/icc8y4cU - only this should be a large monitor and an #API

#API Design Webinar http://t.co/rbDwus37 from @theamiableapi - some very valuable nuggets

Wow. Going to have to get this as a poster just to fully grok it: http://t.co/Z6iie3K5

ITHCWY: PolyLineM support in Catfood.Shapefile: I’ve just updated Catfood.Shapefile, my ESRI Shapefile parser for… http://t.co/ll50wcEi

Cal band at justanswer http://t.co/QOLcbe7e (missed this while at lunch)

Citogenesis: http://t.co/EH5K2xLg

Extensive document dump on Microsoft's shallow anti-Android bullying: http://t.co/tdEhMNLh #patents from @groklaw

Toast sandwich is UK's 'cheapest meal' http://t.co/0LG9zNOl (can't possibly be true - not factoring in cost of electricity!)

Analysis: The Darwin Economy: http://t.co/pSDkxupL

So True: What Your Favorite Map Projection Says About You: http://t.co/dW8pl2uK

Bootstrapped Company Behind iDrive, iBackup Is Fed Up With Patent Trolls: http://t.co/DP6KFLxH

The Real Cost of Patent Trolls: http://t.co/1Cu4C6cV via @bfeld

Flying rhinoceros: http://t.co/MIhWtT3L

Cool: 1% Of Nothing Launches To Get Startups Donating Equity: http://t.co/ZNy7HcZl

3 of 5 stars to Professional Android 2 Application De... by Reto Meier http://t.co/UqCtaJ3Z

'Have the people who designed this protocol really never made the twenty mile drive to San Francisco?' - http://t.co/wWk77ZpQ

Explaining 'Jobs' to Rudy Giuliani: http://t.co/ek78XEe9

ITHCWY: Catfood: Klout and Follower: Klout is building PageRank for people. You get a score between 0-100 based on… http://t.co/rGyYkY9q

Catfood Follower 1.40: http://t.co/79xDac4F via @CatfoodSoftware

Old friends... No CDTV though! At #CHM http://t.co/WGw6VOOL

How much did I used to want one of these! http://t.co/lHhnY0AG

At #CHM for Norvig v Horvitz. Will punch anyone who mentions Searle's Room. http://t.co/wPRO8tYa

Don't do it, like defining π as 4: BBC News - Changes to the world's time scale debated http://t.co/hFkrZi4g

RESTful API Design, Second Edition http://t.co/uZthmj9c #API from @landlessness

Rudy wishes I hadn't just shown him: "Saber-toothed squirrel" from the dinosaur days - Boing Boing http://t.co/Wf7Y0ttH

Marked as to-read: The Lean Startup by Eric Ries http://t.co/MC9M0Iti

Ex-Google Reader Product Manager Posts Scathing Review Of Reader Redesign | TechCrunch http://t.co/DscEAHTw

Google indexing via POST: http://t.co/oM2JmHqI (P.S. may not grok your robots.txt, suggests bending over)

Writing helpful API documentation « The Amiable API http://t.co/rx9QdKyk #API

Oakland PD confused: An Open Letter to the Citizens of Oakland From the Oakland Police Officers Association http://t.co/W5LIBY7D (me too)!

Study: why parents help their underage kids pretend to be 13 in order to use Internet sites - Boing Boing http://t.co/aoUSw5wu

Add your comment...

Related Posts

You Might Also Like

(All Reviews)