Me vs iBooks: The Return. I win (barely)

This blog is for future me and for anyone else wanting to understand some iBooks structure.  It’s not an attack on Apple - I know I’m an extreme case.

Some of you may know my fondness for books.  A habit that led to me buying so many books when the iPad came out I actually broke the iBooks app (too many books to display on the “purchased” screen) which took a year to fix.  Fast forward several years..

It’s been an unexpected few days of technical support. Rumour is that Apple will be changing the iBooks app in an upcoming release and that always makes me nervous.  I buy around 30 books a month and have 3859 on my iPad and iPhone.  Probably about 60/40 iTunes and Amazon.  Losing my books would be equivalent to someone who cares about music losing all their music or a gamer losing all their games.  It would be bad.  Give her space. Don’t try and talk to her. Back away slowly. Bad.

I carefully backup (and have to remove DRM to do it) about once a month.  Why?  Because Apple may decide to drop iBooks at any time and then where would I be with 4000 (or at least 2000) unreadable books?

So I needed to backup and since upgrading to High Sierra that’s been impossible.  The technology I used only worked up to  Sierra.  That’s OK, I use Parallels , can download Sierra at no cost from the App Store and create a VM running Sierra. Of course I had to authorise that VM with my iTunes account so it could read the books which meant deauthorising everything else first since I was at 5 devices. Top tip, if you buy new kit, make sure you deactivate iTunes before flattening the old kit.

Step 1: Getting the books into my VM

In theory because I sync my books to the cloud I should be able to just launch iBooks and auto redownload. Unfortunately that didn’t happen. The books display as in the cloud but have to be manually downloaded.   Understandably selecting nearly 4000 books and telling iBooks to download them all caused it to crash. Repeatedly.  So I needed a better way.

Step 2: Why not just copy the books from my laptop which is the host machine for the VM?

Some digging uncovered that my epubs are stored in

~/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books

so surely I can just copy them over from one machine to another?  Why yes I can and when I launch iBooks they all display - kind of.  They can’t be read and most of the covers are missing but otherwise.. great! Some more digging later and I realised that although I had copied over the books.plist (which is a preferences file containing and index of all the books iBooks knows about), I didn’t get the SQL database that iBooks uses that is in ~/Library/Containers/com.apple.iBooksX.  

So that isn’t going to work. A few hours of trying to get covers to appear or books to be readable and I realised I needed to take a step back.  

Step 3: Maybe I was overthinking this. iBooks builds the index when you add books to the app by choosing “add to library” or just drag and drop them so why not drag the 4000 epubs into iBooks.  I knew they were already there but I tested and it does prompt you with the option to “Replace” all books that are already there instead of creating duplicates (of course what I could really do with is “Skip” rather than “Replace” but I get i’m in a niche situation).

So - drag 4000 books to iBooks and choose “Replace” and wait.  There’s no progress bar. Nothing.  The only way I can see that anything is happening is by launching activity monitor and noting that bkagentservice was consuming 80+% CPU.  Eventually “lots” of books appear.  This is the point where I realise there’s no way to count how many books are in iBooks.  I knew “lots” wasn’t all because I got this dialog “<epub filename> couldn’t be opened because you don’t have permission to view it”

I click OK and got another, and another and another. Eventually having to Force Quit iBooks and restart.

Fair enough.  Maybe when copying over the files from host to guest the permissions came with them and my new guest account doesn’t have permissions.  I spend some time making sure all permissions are OK, applying my new account as well as “Everyone” to that folder and all files contained in it.  I finally test by dragging and dropping individual files into iBooks that work with no error so I decide that error is a red herring - it’s more a “gah! iBooks can’t handle you doing that and has tripped over itself - try adding fewer books”

So now I have a new problem.  What books are missing?  If I knew what books were  missing I could manually add them.   Unfortunately not only do I not know what books are missing,  I don’t know if it’s 10 books or 2000.

Step 4: The search for the missing books

Those filenames aren’t terribly helpful but I know what books I have so I search in iBooks for certain book titles and discover some that aren’t there that should be (and are in my iBooks on my host machine).  How do I find the filename that matches the book title if I know I have the epub in the correct directory?  Here we head to terminal.  In the directory

~/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books

I type grep “some phrase” ./*.epub -r

that “some phrase” could be author, booktitle, any text found in the book.  It’s weirdly powerful so make it as specific as you can.  I find the epub filename for a book I know should be there, I find that the epub  is in the right folder and I drag and drop that epub into iBooks. It works!.  Then I try with some of the files it said I had no permissions for… those work too.  OK so since I know it works and I can’t add all 4000 books at once,  now all I need is a list of what books it thinks I have in my Library to compare with the ones I have on the file system.
Easy right?
Step 5: We’re going to need some XCode
The list of books it thinks I have in the library is in the preferences file books.plist in ~/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books.  Unfortunately the only thing that can easily read  a preferences file is Xcode so off I go into developer territory and installing XCode.  Once I do that I can open and read that preferences file.  Of course XCode is 10GB and my books are 12GB so I’m fast running out of space on the small VM I started with.  
When I do that I see this.  That’s right, an array of 5443 items each one representing a book.  Yes I know I said I had 4000 and it failed to add them all but clearly something is awry in the index too - one problem at a time.
Step 6: A New Plan
I can now read plist files and in theory get an export of items in that file.  If I can export all the books and filenames in the guest machine and do the same on the host machine I can import both lists into Excel and compare to see what files are missing - then manually add them.  Simple!
I don’t do code. I know what I want to do and what I want to do needs code but I will avoid it if I can.  Unfortunately here it’s the simplest way to get what I want.
Using “Script Editor” (part of the native OS) I write a script like this

tell application “System Events”

tell property list file “/Users/gabrielladavis/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books/Books.plist”
set Booklist to value of property list item “Books”
set Output to “”
set Counter to 0
repeat with a from 1 to length of Booklist
set theCurrentListItem to item a of Booklist
try
set author to artistname of theCurrentListItem
set booktitle to itemname of theCurrentListItem
set thefile to sourcepath of theCurrentListItem
set Output to Output & author & “,” & booktitle & “,” & thefile & return
end try
set Counter to Counter + 1
if Counter mod 50 = 0 then
log (Counter)
end if
end repeat
log Counter
return Output
end tell
end tell

The counter was so I could see it was actually doing something as it ran.  The “try” was to check if the item has an author etc since my PDFs often didn’t and the code would fail otherwise.

It may not be pretty but it gave me what I wanted which was thousands of lines like this

Pamela Hartshorne,Time’s Echo,/Users/gabrielladavis/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books/1F31185F755DD6B65C00B1CF641409B4.epub

Riggs, Ransom,Miss Peregrine’s Home for Peculiar Children,/Users/gabrielladavis/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books/46D721416EA9EBB037E767DF155A4395.epub

 

Step 7: An afternoon with Excel

Running the agent twice against the host and guest books.plist gives me the data I need.  The host machine plist gives me 3789 entries and the guest machine 5443 entries. It appears every time I attempted to drag and drop a file in the guest copy of iBooks it created a new plist entry.  I enjoy data manipulation in Excel and after cleaning things up and playing with INDEX/MATCH I discover…. it’s not going to work.

The problem is that the plist filename is only updated when the books are added to the library so there was an unreliable mismatch between the guest and host plists.

Step 8: Take a step back and try playing by Apple’s rules

I take a copy of the iBooks directory into another folder (“movedbooks”)then I launch iBooks itself and (making sure iCloud is completely disabled on the guest machine so there’s absolutely not syncing to any device) I remove every.single.book from within iBooks.  Several scary minutes later iBooks is empty and so is the iBooks folder and the plist file.

Meanwhile I still have a copy of all the books in “movedbooks” - I know iBooks didn’t like me dropping 4000 books in but at this point I’m prepared to meet it half way.  After some trial and error, I copy the books in 250 or so at a time.  I verify they are added correctly by checking the books count that appears in the iBooks folder.  It takes about an hour but when I’m done, the iBooks folder is 170 items smaller than the movedbooks backup.

GAH

Step 9: The search for the missing books

I now need a tool to compare the contents of the movedbooks folder to the ibooks folder and tell me which files re present in the first but missing in the second i.e. are missing from iBooks.  A free app called “Compare Folders” does that for me nicely.  Unfortunately it won’t let me export the list but at list I can see the list of missing files.

Step 10: The final piece

170 is a manageable number so now, one by one, I find the missing files and drop them into iBooks.  That works and I end up 3849 books in iBooks and in the directory.  If you’ve spotted that’s 10 less than I should have then congratulations, that’s not a typo.  10 books completely resisted being added to the guest, no error, nothing, they just won’t add.  Even weird when I check my Excel spreadsheet and decide I don’t care about those 10.  But I make a note in case in care in the future.

So that’s it.  I shouldn’t need to do this again as I can add books in small numbers as I buy them and never again have to add all books I’ve bought.  In theory.

A final note.  If you have a Mac , buy yourself a copy of DiskWarrior, but that’s a story for another day.

{blink}So THAT’S the future{blink}

It’s been a few weeks since I’ve posted here.  The end of last year was a juggle of many different pieces of work and learning new technologies but more on that later. I did however take my eye off the ICS (IBM Collaboration Solutions) ball waiting for the HCL deal to firm up and find out more what was going on.

As you may know from my previous post, at the end of October IBM entered a partnership with HCL whereby the latter took development ownership of all Domino products including Verse and Traveler as well as Sametime whilst IBM continued to own the license model, support and most importantly strategy.  As part of that announcement we were told of an upcoming series of workshops around the world called Domino Jam 2025  which were to determine the future path of both Domino and Sametime (so not just Domino and nothing to do with the year 2025!).

Last Friday I (along with about 50 other people) attended a London Domino Jam at IBM South Bank which was hosted by the senior development team at HCL (who transferred in from the same roles at IBM) and the product management team at IBM.  Up until a week or so ago I would say I was more curious and cautiously optimistic than excited.  I had been in coversation with someone in the development team at HCL who I have known from IBM days for 20 years and his introduction to HCL and his enthusiasm for the future sparked my own.  Let’s just say the HCL team seem to be people who have been long immersed in these products, believe in them and are now being let off the leash to develop for the future. During the day we were casually told that there would be new product releases guaranteed in 2018 including

Domino 10

Notes 10

Traveler 10

Verse (10?)

Sametime Instant Messaging 10

That was and is very encouraging news and IBM seemed bemused that several of us in the room kept asking for clarification and confirmation of a thing they thought we already knew.

As part of the Domino jam workshop we were split into groups and asked to brainstorm things like “your biggest pain points” and “what features would you like to see in the future” and then prioritise and present them.  These workshops are going on around the world right now (there’s one in Geneva I believe today) and you can register for them here https://www.ibm.com/collaboration/announcements/domino-jam2025.  In addition if you can’t attend in person IBM are hosting a Domino Jam Forum from Jan 16 - Jan 19 where you can provide your feedback directly online.  See this blog for more information https://www.ibm.com/blogs/collaboration-solutions/2018/01/11/announcing-domino2025-online-forum-january-16-18-2018/

the “#domino2025 Online Forum” will be active for fifty-five hours across the globe to gather your business and technical input and prioritization.” (I prefer “priorities” but I get what they mean :-).

If you are in any way invested in the future of ICS products either mail or instant messaging or conferencing then this is a serious effort to hear what you want and don’t want.  I can tell you there was some very honest and harsh feedback as well as some pretty extreme ideas thrown out by the teams last Friday and we were encouraged to do that.   I know for some of you it’s asking a lot but dig deep, find that kernel of optimism that’s still left, or just throw in your lot because it does no harm to do so and may do a lot of good.

This is an opportunity to help form the long term strategy and direction of products many of us love and believe in.  Take it.

A New Era, A New Future, A New Domino

Some of you may have already seen the tweets out of HCL and the announcement from IBM on the new strategic partnership for ICS products that IBM have just entered into with HCL.  To explain things as simply as possible this means that HCL will take over the development of most of the ICS products whilst IBM continues to manage the product strategy, marketing and licensing.  The products involved include

Domino
Notes (on premises and SmartCloud)
Traveler
Verse
Sametime
IBM Client Access
IMSMO (mail support for Microsoft Outlook)

So what does this actually mean for us as Business Partners and, more importantly, for customers?  In my opinion this is very good news.  The products will benefit from significantly more development investment and resources,  with the existing IBM development teams on those products moving under HCL  In addition IBM will continue to manage the product themselves (using the existing offerings management teams) as well as the licensing, and the strategic direction.

There is no longer any End of Life date for Domino, not even “at least until” dates.

As far as customers are concerned, nothing will change other than an acceleration in the investment and development of products including the announcement of Domino 10 for 2018 and the #Domino2025 project.  Even submitting PMRs will continue in the same way.  There will be no customer - HCL direct relationship.

What is Domino2025? Otherwise known as Project Sapphire this is a strategic and ongoing product development initiative IBM will be starting in November where they will be taking feedback on what people want to help drive the future of Domino.   You can tweet your feedback using #Domino2025 and look forward to workshops taking place worldwide as a continual process to design future (post v10) Domino.

I have a lot more thoughts which I’ll share over the coming days but when I first heard about this and considered it I realised that this is a huge opportunity and a step forward for all the products involved.  I hope you agree.

The birth of a new Domino!

How Apple’s UI Helped Scammers Steal

This week someone I care about very much was scammed out of thousands of pounds.  I am just getting past my anger over it and have spent the past few days trying to work out what I could have done to prevent it happening. I work in security, I believe I have told everyone I care about how to protect from the most basic things but Apple introduced a layer of obfuscation that I hadn’t told anyone to look for, because I hadn’t fully noticed it myself.

So what happened?  This person received an email from someone they knew (let’s say “Gabriella Davis’) with a simple “Good morning” type one liner.  They read the email on their iPad and replied to “Gabriella”.  Several back and forths later this conversation turned into a request to move some money.  In this business situation it wasn’t that unusual a request.  Obviously the “Gabriella” turned out to be a fake email address and the transferred money sent to “Aviva Insurance Ltd” (a valid company) was actually sent to an account owned by someone else and quickly extracted and closed down.

Why didn’t the person who was contacted check that the email they received was from the right Gabriella Davis?   They did.  It is one of the most basic things I teach people, always verify and dig into the email address.  However on iOS the email address was shown incorrectly.  Say the email was from “Gabriella Davis <fakeaddress@gmail.com>” and my real address is “Gabriella  Davis <gabriella.davis@turtleblog.info”> well Apple kindly matched the “Gabriella Davis” phrase part with a contact (me) in his contacts and showed not only my photo on the email as the sender but also - when clicking on it - filled in the gabriella@turtleblog.info address.

Even though the reply actually went to fakeaddress@gmail.com,  there was no way to see that from iOS.  

The person concerned took Apple’s representation of my contact information and my photo on the email as validation that it came from me and he was talking to me.  He wasn’t.  The same email opened in both Notes and Outlook immediately showed the fake address and the fake address was obvious when choosing reply from those clients.  it simply would not have happened if he hadn’t been using iOS.

My instructions to always check the sender address hadn’t been spoofed and always check you are sending to the right person turned out to be the worst possible advice in this case because the contact information Apple prefilled in gave a layer of confidence to the email that otherwise wouldn’t have been there.  “Of course it’s Gab, Apple are even showing me her picture and her email”.

I will probably not open comments on this entry as it isn’t entirely my story to tell and there is lots more information I am not prepared to share publicly.  If you know me and have a specific question you can reach out and I may be able to answer.  Otherwise please warn people you know.

  1. Never reply to important emails on an iOS device
  2. If in doubt , even a tiny bit of doubt, always forward and re-address
  3. Any sense of urgency in an email should be a red flag regardless of anything else
  4. There is no replacement, and always time,  for verbal verification

 

A Plea For 3 Mins Of Your Time To Read This

Recently a friend’s wife was diagnosed with kidney failure. Although she is on dialysis,  she is also on a registry hoping for a donor kidney.  After a few discussions and some internet research, I realised how little I know or understand about donating a kidney. How doing so could add years to a loved ones or a strangers life with little risk to myself.  When someone is on dialysis and waiting for a donor kidney, they need strength and they need hope.

Here’s a few things I didn’t know and I want to share because maybe you didn’t know them either.  I apologise in advance for my ignorance which may be exclusively mine. 

1. It’s not true that the most best match will be from a family member.  Genetic compatability is one aspect but with improved anti rejection medicines it’s very possible and often common for a friend or even a stranger to a donate. 

2. Anonymity is maintained throughout the process if you wish and the recipient may never find out that you tested or if you were a match.  You can start the testing process anonymously and choose not to proceed at any point.

3. The first step in finding out if you’re a match is simply to see if your blood type is a match. If it is you can move onto the next step which is a DNA match test.

4. You can choose to be tested to match for a specific person or to be added to a paired/pooled registry where your kidney will be given to someone you match with and the person you wanted to donate to will get prioritised higher on the match registry or even add your details to a general registry which commits you to nothing.

5. The path for potential donors involves not just ensuring you are physically able to donate a kidney but also emotionally prepared to do so. After you are a match you will often be assigned a counsellor to work with you on the decision to donate and the process itself.  Again if you decide to stop at any point, that is entirely confidential and anonymous

If you want to know more about kidney donation and what’s involved then please take a quick look at these sites http://www.giveakidney.org/ and https://www.kidneyresearchuk.org/health-information/living-donor-transplantation

To register as an organ donor or a living kidney donor in the UK please read this NHS site https://www.organdonation.nhs.uk

Bending iBooks (Mis)Behaviour To My Will

For those of you that don’t know, I buy a lot of books.  Around 30 - 40 a month.   I used to buy exclusively physical books but I like to keep ones I enjoy to re-read and I am fast running out of house so now about 80% of my book purchases are digital.  Sometimes from the iBookstore and sometimes from Amazon.  I refuse to play the DRM game but that’s a story for another day.  I now have around 3500 books in iBooks that I read via that app on my iPad and phone. In 2011 (I think) Apple introduced “Collections” so I could group books together to make them easier to find.  Apparently Collections have a maximum limit but I’ve never reached it because beyond about 40 they simply aren’t useful to have to scroll through. Here are a few of mine, I have 25 or so more

The problem is two fold.  With 3500 books and only 40 collections that puts about 90 books per collection which is a lot to scroll through unless they are sorted within the collection.  You can manually sort but Apple has a tendency to randomly resort everything by “most recent” (which seems to be triggered by any kind of update) so you can spend your entire life trying to sort things together.  Take Ben Aaronovitch for instance, a writer a like and I have filed his books under Steampunk/Fantasy (they are “urban fantasy”) but when he publishes a new book every two years it appears at the top of the collection, because it’s the newest.  Meanwhile all his other books are dotted all over the place and what I want to see is what I’d see if I shelved them at home - all the books by one writer grouped together.  iBooks has no way for me to do that and make it stick.  I can view by author but that’s not the same thing as I can’t move around in that view.

So what I wanted was simply to be able to have all books by each writer grouped together to make them easy to find in each Collection.  It turns out the fix for me was to turn iBooks (mis) behaviour against it.  I discovered that adding a book to a Collection actually updates a timestamp within the epub which marks it as recent for sorting purposes.  Even if the collection you are moving a book into is the same one it’s already in so this is what I did

  1. Step 1 in the iBooks app on OSX or iOS search for a writer “Ben Aaronovitch”
  2. Select all books found
  3. On OSX right mouse click and choose “Add To Collection” and select the Collection you want the books in, even if it’s the Collection they are already in
  4. On iOS choose “move” and select the Collection you want the books in, even if it’s the Collection they are already in
  5. That’s it.  No matter where all my Ben Aaronovitch books were they will now be grouped together and sorted at the beginning of my Collection.  I can then go through and do the same to any other writers I want to group

The nice thing is that this is a quick and easy process that can be repeated anytime you buy or download a new book but a writer you’re collecting.

Or maybe it’s just me 🙂

Heads Up For UK Amazon Echo Buyers

After spending far too long (i.e. more than 10 mins) on tech support with my Amazon Echo today I finally rang them.  My problem was that it refused to acknowledge I had Amazon Prime and that TuneIn radio didn’t work so I couldn’t say “Alexa, play BBC Radio 4” for instance.

Calling Amazon UK support and I’m told they entirely messed up the UK Echo devices which ship to auto register with amazon.com.  Apparently tech support have to manually change your Echo registration on their end to force it to connect to the UK site instead of the US and they are “rushed off their feet” doing that as each person calls.  It should be sorted by tomorrow.

  1. The setup was a pain and far too confusing for anyone not technically savvy (say my mother in law)
  2. There is no remote control supplied although one exists they are just too cheap to supply it with the device
  3. They shipped it with the wrong configuration assuming there is no other country other than the US.
  4. You have to call them to get it manually fixed

Amazon is definitely no Apple …

IBM Lifetime Champion Award - 

Today during a lunch for IBM Champions, Amanda Bauman announced a new IBM Lifetime Champion award created this year and given to Theo Heselmans and I.  It was a surprise to say the least and the standing ovation my fellow Champions gave us (along with the hugs and handshakes) sent me into shock

2016 marks the 20th year of Turtle and I have loved and still love working with the products and people in this community (call it what you will, you know who you are) for every moment of that time.  I am beyond happy that I have been part of helping it grow and flourish and that I have learnt so much from so many of you.  

I will do my best to keep learning, writing, sharing and working.  For those of you that have come to my presentations, worked with me, taught me, encouraged me, nominated me and become my closest friends

Thank you

Tomorrow I’m on stage at the closing session of IBM Connect.  Deep breath and wish me luck.

Return Of The Watch

Watches are gone or going the way of the dodo right? I mean actual watches that just tell time not watches that try and be supercomputers.  Everyone tells the time on their devices now so you don’t get a watch to do just that.  Right?

I don’t wear a watch.  I haven’t worn a watch since I was a child, I think my last watch memory was seeing 1979 click over to 1980 on my casio digital watch at new year’s eve (yes even as a child I knew how to party).  I stopped wearing watches as a child because I kept losing them.  As I got older I didn’t want a watch because I felt that paying too much attention to time was unhealthy and stressful.  I think I have a good internal clock and I can always tell when a kitchen alarm i’ve set is about to go off about 5 seconds before it does :-).  On top of that, working with computers taught me to stop wearing anything on my wrists - it slows me down, irritates me and I end up taking bracelets off and - yes - losing them.

So this is a long way of saying, today I bought a watch.  Not an expensive one.  Just a swatch but I finally decided a watch is what’s missing from my life. You see I get very little “down” time.  When I do get downtime I know I have a set window to relax before I have to get some more work done.  That means I have to keep picking up my phone to check the time.  When I pick up my phone to check the time, I see mail notifications or text messages or am reminded of 1000 other things I should be doing in that moment instead of just sitting and reading.

The devices that tell me the time are also now inextricably linked with “work” and therefore “stress”.  A watch is now the easiest and least stressful way to actually tell the time.  It’s an interesting full circle and I wonder if it’s just me.