jawj / iphoto-flickr

Ruby + Applescript to incrementally back up my iPhoto library to Flickr (abandoned due to the advent of Photos.app)
105 stars 19 forks source link

iPhoto albums not being recognised #7

Closed kamaldshah closed 10 years ago

kamaldshah commented 10 years ago

Probably the new iPhoto album definitions were changed. So, I get a "0 standard albums in iPhoto" after all my photos are uploaded despite having a bunch of albums.

jawj commented 10 years ago

Oh bugger. I used AppleScript rather than sqlite mainly because I was hoping to get around this sort of thing by sticking to public interfaces — and a fat lot of good that did! I'm not on Mavericks, so I can't test this yet, but I'm sure I'll get there eventually.

kamaldshah commented 10 years ago

Sure, will wait! Awesome tool btw!

verbitan commented 10 years ago

Just to chime in on this, I'm running Mavericks with iPhoto 9.5 and this script has recognised the albums correctly, so I think something else is going on here.

jawj commented 10 years ago

@kamaldshah These are definitely regular albums, not events, smart albums, or something else?

kamaldshah commented 10 years ago

Yes, all regular albums.

jawj commented 10 years ago

Hmm, OK. What do you get if you run this from AppleScript Editor?

tell application "iPhoto"
  set adata to {}
  set ras to albums whose type is regular album
  repeat with ra in ras
    set end of adata to {ra's name, count of ra's photos}
  end repeat
  adata
end tell
kamaldshah commented 10 years ago

I get a bunch of such entries enclosed in braces: {"Birthday 2013", 40}

Birthday 2013 is one of my albums btw. Should I post the whole response? Its basically {{"Birthday 2013", 40}, {"Nishant Wedding", 15},....}

jawj commented 10 years ago

That's what you should get.

How about if you add this line to flickrbackup.rb just before the comment # upload new files, around line 222?

puts albumData
kamaldshah commented 10 years ago

Tried that. No luck. Still:

0 standard albums in iPhoto

after uploading some pics that I imported recently!

jawj commented 10 years ago

Yeah, that wasn't expected to fix things, but to provide some debugging info. Did you get any new output just after the message 'N photos not yet uploaded to Flickr'?

kamaldshah commented 10 years ago

Yes actually, here it is: (Mahabalipuram is the name of one of my albums)

918:955: execution error: iPhoto got an error: "4.294967323E+9Mahabalipuram" doesn’t understand the “write” message. (-1708) {}

jawj commented 10 years ago

That narrows down the problem, but I still don't know why it's happening. I wonder if it's related to software versions or locales.

Can you run this one-line script in AppleScript Editor and tell me the output?

system info

And if you don't mind, I guess it might be useful if you posted the whole {{"Birthday 2013", 40}, {"Nishant Wedding", 15},....} ouput, in case there's something special about the album that's failing.

kamaldshah commented 10 years ago

Sure, here is the system info output:

{AppleScript version:"2.3", AppleScript Studio version:"1.5.3", system version:"10.9", short user name:"kamal", long user name:"Kamal Shah", user ID:501, user locale:"en_IN", home directory:alias "Macintosh HD:Users:kamal:", boot volume:"Macintosh HD", computer name:"kamal (2)", host name:"kamal-2.local", IPv4 address:"192.168.12.95", primary Ethernet address:"b8:e8:56:0e:fd:de", CPU type:"Intel 80486", CPU speed:1300, physical memory:4096}

and here is the complete output to the earlier command:

{{"Last Import", 47}, {"Mahabalipuram", 14}, {"ShrishaTrip", 26}, {"Tsunami Group Dinner", 31}, {"Alankrita", 14}, {"Old Photos", 21}, {"Prasan Marriage", 70}, {"Gandipet Picnic", 60}, {"Biopsy Slides", 7}, {"Naman1", 32}, {"Naman2", 14}, {"Kodaikanal 05", 33}, {"effigent 5th Birthday 2005", 209}, {"Friends", 27}, {"Solos", 35}, {"effigent 6th Birthday 2006", 145}, {"Naman3", 79}, {"Birthday 2006", 63}, {"VCA-Cookout", 129}, {"effigent Feb 13th Party", 43}, {"Prasads", 7}, {"Holi", 31}, {"JobFair", 53}, {"effigent March 30th Party", 4}, {"PragatiResorts", 35}, {"Cricket", 4}, {"Nidhi Naming", 42}, {"effigent April May Parties", 21}, {"Lahari Resorts", 255}, {"Independence Day 2007", 14}, {"Effigent General", 9}, {"Tanay", 4}, {"effigent 7th Birthday 2007", 430}, {"Birthday 2007", 12}, {"Hogenakkal", 23}, {"Nagarjunasagar", 489}, {"Goa 2008", 175}, {"Pragati - July 13 2008", 23}, {"Logos", 1}, {"Cricket Matches", 493}, {"effigent 8th birthday 2008", 13}, {"Ethipothala Oct 2008", 3}, {"Naman Nidhi", 6}, {"HPS Reunion 2008", 7}, {"Christmas 2008", 15}, {"Ex Effigent Dinner", 6}, {"Goa 2009", 443}, {"Hoginakkal Feb 2007", 0}, {"Temp", 0}, {"Karan in the US", 60}, {"Vizag Araku", 705}, {"Dialysis.org.in", 7}, {"X Rays", 5}, {"Grene Office 15th Jan 2010", 19}, {"Coorg Jan 2010", 115}, {"Nephroplus Opening", 163}, {"Birthday 2010", 5}, {"FloorPlans19", 3}, {"Dubai Dec 2010 Daddy Mummy", 150}, {"StonePlus-Others", 15}, {"StonePlus-Granites", 70}, {"StonePlus-Marbles", 5}, {"Goa Jan 2011", 121}, {"Aashayein 2011", 177}, {"NephroPlus First Anniversary 14th March 2011", 18}, {"X Rays", 4}, {"NPEMPics", 42}, {"Dilip Archana US Trip Part 2", 91}, {"Dilip Archana US Trip Part 3", 352}, {"Dilip Archana US Trip Part 1", 341}, {"NP BH Pics", 30}, {"NPMBNPics", 3}, {"Banjara Hills", 11}, {"East Marredpally", 7}, {"Mahbubnagar", 3}, {"StonePlus-Veneers", 3}, {"Birthday 2011", 25}, {"Battle at Poorna Tiffins Oct 2011", 14}, {"NP Diwali", 15}, {"NP @ APNA", 7}, {"NP Pavan Birthday", 5}, {"Samiir@NP", 16}, {"Sumeru", 5}, {"ISN 2011", 5}, {"Effigent Reunion 2011", 155}, {"Aashayein 2012", 285}, {"NP Founders", 45}, {"Kamal Pre 1997", 27}, {"Rare Disease Day", 18}, {"World Kidney Day 2012", 164}, {"Santoshnagar Pooja", 99}, {"GP CME", 121}, {"NP KARMN Pics", 8}, {"Subhash Birthday 2012", 6}, {"Darjeeling 2012", 111}, {"NephroPlus Cricket", 12}, {"Kamal US Canada Trip 2012", 739}, {"Birthday 2012", 51}, {"Aashayein BLR 2012 ", 108}, {"Malay Wedding", 33}, {"NephroPlus", 83}, {"NP-Agra", 41}, {"Aashayein", 462}, {"Leonia with Effigent Friends", 12}, {"Agra - April 2013", 7}, {"Aashayein Agra 2013", 87}, {"NP Directors' Offsite @ Leonia", 56}, {"US Trip 2013", 81}, {"Global HHD Forum Videos", 23}, {"Birthday 2013", 40}, {"Aashayein Delhi 2013", 390}, {"Pune Launch", 6}, {"Nishant Wedding", 15}}

jawj commented 10 years ago

Thanks. I'm still not certain what the problem is, so I've asked a question on Stack Overflow (http://stackoverflow.com/questions/20521962/mysterious-applescript-error-4-294967323e9mahabalipuram-doesnt-understand-t).

This thread — https://discussions.apple.com/thread/5132915 — seems to imply that the cause could be some OS corruption, so it might be worth trying to reinstall the latest combo update (if there is one for Mavericks).

jawj commented 10 years ago

@kamaldshah, can you try this?

Open flickrbackup.rb in TextEdit (or BBEdit, TextMate, etc), and where you see these 3 lines (around line 194):

write albumData to fp as Unicode text
write albumPhotoIds to fp as Unicode text
write nul to fp as Unicode text

Replace them with these:

tell application "System Events"
    write albumData to fp as Unicode text
    write albumPhotoIds to fp as Unicode text
    write nul to fp as Unicode text
end tell

i.e. we're simply wrapping the file-writing commands in new tell application block.

kamaldshah commented 10 years ago

Tried that. Here is the error after the photos not yet uploaded messages:

952:989: execution error: System Events got an error: File some object wasn’t open. (-38) {}

kamaldshah commented 10 years ago

I actually then tried what user CRGreen suggested in the stack exchange thread you posted and it looks like it is working now! Will keep you posted once done.

kamaldshah commented 10 years ago

I get these kinds of errors while creating the photo sets and adding the photos to them:

Creating new photoset: 'ShrishaTrip' ... 'flickr.photosets.create' - Invalid primary photo id () ... 4294967372 -> X Adding photo 4294967338 -> to photoset 4294967372 -> X ... 'flickr.photosets.addPhoto' - Photoset not found Adding photo 4294967339 -> to photoset 4294967372 -> X ... 'flickr.photosets.addPhoto' - Photoset not found ....

Some of them work but some are erroring out like this. Any ideas?

jawj commented 10 years ago

If you've deleted any of the photos or photosets uploaded/created by the tool, or if any have failed to upload, future operations on photosets may fail. In this case it's failing to create a new photoset because the photo it's picked as the primary photo for the set doesn't exist on Flickr, and then adding photos to that photoset is also failing. Possibly the script should do more error checking around this, but that's not a high priority for me at the moment.

On 12 Dec 2013, at 01:04, kamaldshah notifications@github.com wrote:

I get these kinds of errors while creating the photo sets and adding the photos to them:

Creating new photoset: 'ShrishaTrip' ... 'flickr.photosets.create' - Invalid primary photo id () ... 4294967372 -> X Adding photo 4294967338 -> to photoset 4294967372 -> X ... 'flickr.photosets.addPhoto' - Photoset not found Adding photo 4294967339 -> to photoset 4294967372 -> X ... 'flickr.photosets.addPhoto' - Photoset not found ....

Some of them work but some are erroring out like this. Any ideas?

— Reply to this email directly or view it on GitHub.

jawj commented 10 years ago

I've now added a tell me block around the file writes, which seems to have fixed the AppleScript errors.