bsdz / google-drive-remarkable-sync

Apps Script library for synchronising Google Drive folder with Remarkable reader.
MIT License
118 stars 17 forks source link

2-way sync with download API #17

Closed agurvich closed 3 years ago

agurvich commented 3 years ago

Just taking a look so far, but this looks really awesome! Thanks for putting in the time!

I was wondering if you agreed it would be straightforward to add a download block like your upload block that would push changes on the remarkable to Google drive. For my use case, I'd like to annotate PDFs and then have them synced to Google drive (which is then synced with another service). It seems like a lot of the pieces are here like: crawling the remarkable to find files that aren't in the drive and checking metadata for version updates.

It even seems like you have an open PR to download API. Curious before I sit down and dig in if there's something I'm missing here that makes it harder than it seems?

Cheers.

bsdz commented 3 years ago

IRCC the annotations are stored in a separate annotations file (rmlines). You'd need to figure out a way to flatten those annotations into the PDFs (in AppsScript) or perhaps upload them back alongside the original PDF. My memory is a bit hazy as haven't really looked at it recently.

agurvich commented 3 years ago

Ah yeah, that makes sense. Downloading off the RM cloud by hand through their app definitely seems to have a processing step, I'll fire up an ssh and explore a bit. Thanks for the tip!

tkukurin commented 3 years ago

@agurvich I have forked this repo to implement this exact functionality. :)

As @bsdz mentioned, downloaded blob from ReMarkable will be a zip file with pdf + rmlines.

For my purposes I manually run this colab script (based on RMRL) when I want to convert a .bin file to annotated .pdf. You could probably setup an automated GDrive integration if the zip -> pdf conversion is something you intend to do frequently.

agurvich commented 3 years ago

Ah wow! I'm so glad I asked then before sitting down to do it. I'll take a look at your fork then and probably raise an issue there if I run into any trouble, thank you for sharing!

agurvich commented 3 years ago

@tkukurin , seems like your fork doesn't have issues enabled (also seems like they are disabled by default, weird). Not sure if you want to enable that in the settings and we can take the conversation there but I have bumped into something I can't get past :(

  1. I didn't realize I needed to enable the advanced Drive API service (should probably add to Readme). I got there eventually when it didn't know what Drive was.

In:

  let cache = {};
  let cList = JSON.parse(gdFile.getBlob().getDataAsString());
  for (var doc of cList) {
    cache[doc.ID] = doc;
  }
  return cache;
}

gdFile.getBlob() is raising an error because the gdFile object is missing the getBlob method. The weird thing is that it works when you use it in the constructor but when the script tries to update the cache after downloading something from the remarkable cloud it comes back with some other gdFile that has a whole bunch of methods related to setting the metadata (way more methods even than the working gdFile object has) but nothing about accessing the content (and certainly no getBlob method). Any idea what could be going wrong?

Here's the callstack of the of the failed getBlob call: Screen Shot 2021-03-29 at 12 24 03 PM

And here's just a subset of the methods this gdFile object has related to the metadata Screen Shot 2021-03-29 at 12 27 30 PM.

It does say it's a json, that it has the right name, etc... it's just missing the getBlob method 🙁

tkukurin commented 3 years ago

@agurvich Thanks for letting me know. The GitHub repo is not perfectly in sync with my GDrive implementation, so that's likely the culprit of this error -- I've updated code on my master branch, would you mind checking if things work for you now?

P.S. I've enabled issues on my forked repo so feel free to submit there in case of any problems.