Giter VIP home page Giter VIP logo

rmapy's Introduction

rMapy

This is an (unofficial) Remarkable Cloud API Client written in Python.

API Support

  • ☑️ List content in the cloud
  • ☑️ Work with documents & folders
  • ☑️ create a folder
  • ☑️ move / rename a document or folder
  • ☑️ create a document
  • ☑️ edit a document
  • ☑️ delete a document or folder
  • ❎ cli interface
  • ❎ export pdf with annotations

rmapy's People

Contributors

adeelk93 avatar agentydragon avatar bsdz avatar dancorne avatar dependabot[bot] avatar jacobian avatar jodergrosse avatar ruebeckscube avatar sabidib avatar singofwalls avatar subutux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rmapy's Issues

Outdated results of rmapy.get_meta_items()

Maybe this is a noob error, but from my understanding of the api, rmapy.get_meta_items() is supposed to query the reMarkable cloud and return a collection that effectively includes all the current content of it.

Now I have been getting strange results to my calls, where files that were removed on reMarkable and are no longer present in other clients like the official desktop client and the mobile app still appear in the collection returned by rmapy.get_meta_items(). Similarly, moved files or renamed folders are not returned as such. Is there some cache I would need to clean? Or do I need to run another command to actually fetch changed items?

I have already tried reauthenticating and obviously I have tried it in a clean python shell without existing variables that could hold old versions of it.

Any help would be much appreciated. Thank you

QUESTION: using pageID for saving rm pages

Hi, first a little bit of background: I am using this program as a first step to later do some analysis, and I realized there is a mismatch between how and what this program outputs (Zip Files) and the current reMarkable App way of saving the files in two ways:

  1. This program does not save any metadata file for the documents (although the information is partially there)
  2. The individual rm files are saved with the page number instead of the page ID.

While I know that those two behaviors are similar in rmapi, I don't see the reasoning behind that, since we then have an incompatibility between the later programs that use the saved files by the official apps and the files from this application. However, since I've not used all the program functionalities, I could not say it for certain.

So, is there a reasoning behind having those two differences with the official app?

Thanks

PS: I have the changes in code already done and I could contribute in case the output of the discussion is that is a good idea to follow the same approach as the official apps.

Example

Hello, could you show a usage example? How to connect to API and upload a file.

with zipfile.ZipFile('test.zip', 'w') as myzip:
myzip.write('test.pdf')
client = api.Client()
doczip = document.ZipDocument()
doczip.zipfile = myzip
client.upload(doczip, upload_folder)

Am I doing this right?

Thanks in advance for your answer.

register_device results in http code 400

I figured
response = self.request("POST", DEVICE_TOKEN_URL, body)
should probably be
response = self.request("POST", DEVICE_TOKEN_URL, body=body)
(api.py line 120)

Downloading + extracting PDFs

Hi there!

I've been playing around using this and it's great, thank you for your work. I can successfully upload documents to my RM, but I can't figure out how to download ZipDocuments and extract them - I'd like to create a script that can automatically encrypt notebooks I make and return them to the RM Cloud. Here's the code I have working - no idea if this bit is even right or not!

from rmapy.api import Client, ZipDocument

rm = Client()

rm.renew_token()

Doc = [ i for i in rm.get_meta_items() if i.VissibleName == "TestDoc" ][0]
print(Doc)

Printing gives <rmapy.document.Document document ID>.

downloaded_file = rm.download(Doc)
print(downloaded_file)

Again, this yields <rmapy.document.ZipDocument document ID>. Looking at the code, I'm not sure what I should do next. Thank you!

reMarkable rolling out a new API for cloud storage

According to juruen/rmapi#187 it seems as though a new API for the remarkable cloud is being rolled out that uses GCS directly.

It seems to be rolling out slowly to different users over the last 2 weeks. I'm still not on it as my cloud seems to be syncing correctly using rmapy and rmapi.

@subutux Have you noticed any issues with your syncing?

If anyone is on the new API, I would gladly pair with them to work on figuring out the new API and get a PR merged into rmapy/rmapi.

Any hint why the time are returning incorrect format?

First of all, thanks for putting this; it is awesome. I want to contribute to the project. If there is something you will like to integrate, let me know I can hack it during my weekend.

So I was having this issue, and I couldn't figure out what was wrong with my device. But I used the API and found that all the documents I send to the device via the extension are mostly coming with the wrong date 0001-01-01T00:00:00Z i don't know why.

With this, I am not able to display the newly send content to the device.

Do you have any workaround? Or point me to a solution?

Step to reproduce :

With the chrome extension, try to send a document to your device via the chrome extension.

With this code, you can see the document but with the wrong date.

# create an API instance
collection = rmapy.get_meta_items()

docs = [ doc.to_dict() for doc in collection]
for doc in docs:
    doc["ModifiedClient"] = parser.parse(doc.get("ModifiedClient"))
    print(doc.get("VissibleName"),  doc.get("ModifiedClient"))   

For my side, I am getting the following documents :

Meet Aiden, your new AI coworker – TechCrunch 0001-01-01T00:00:00Z
CENI: la religion énerve | Politico.cd 0001-01-01T00:00:00Z
Guide: How To Answer Chevening Scholarship Interview Questions - Cynthia Kimola 0001-01-01T00:00:00Z
wddIRHD-LiwIc_L0i7yNuPT5fNw (1).pdf 0001-01-01T00:00:00Z

Metadata json file not added to zip file

I just started using my brand new Remarkable and I would like to set up a solution in order to avoid using remarkable cloud, and use my own private cloud instead.

I started playing with rmapy, it seems an excellent project with almost all I need, thanks for the awesome work!

Just, I noticed that when dumping a zip file (eg. created from a pdf file), rmapy does not include the metadata json file. This prevents xochitl from "seeing" the notebook when I manually upload its (uncompressed) contents into ~/.local/share/remarkable/xochitl. But if I add the following line to rmapy.document.ZipDocument.dump():

            zf.writestr(f"{self.ID}.metadata", json.dumps(self.metadata))

it works as expected (i.e. I see the file in xochitl).

Moreover the VissibleName key in metadata dict created by rmapy.document.ZipDocument seems to be wrong, and actually if I leave as it is, I see the uploaded file but it has an empty name in xochitl. If I change it to visibleName it works as expected (i.e. I see the file with its name).

Are these two things on purpose (eg. they are needed to make things work with remarkable cloud) or are they bugs/typos?

(I already answered myself to the second question having a look at https://github.com/splitbrain/ReMarkableAPI/wiki/Storage 🙂 : it's not a bug, the typo is in the remarkable cloud API; the metadata json schema is slightly different from the one used within the device...)

rmapy currently does not support new sync API

I'm posting this issue to hopefully help folks coming by in the future. Currently it seems that all forks of rmapy do not fully support the updated sync api.

This fork has a newapi branch which seems to successfully log in, but other issues exist.
https://github.com/AaronDavidSchneider/rmapy/tree/newapi

This Go based API seems to be working well for me, with a possible issue deleting files on a tablet with the 3.6.1.1894 OS version.
https://github.com/juruen/rmapi

Download fails with KeyError: "There is no item named '<UUID>.thumbnails/0.jpg' in the archive"

Downloading files currently always errors:

rma = rmapy.api.Client()
rma.renew_token()
assert rma.is_auth()
collection = rma.get_meta_items()
filename = "examplenote"
doc = [f for f in collection if f.VissibleName == filename][0]
data = rma.download(doc)
>>>>>

data = rma.download(doc)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-13-b02e19e143e3> in <module>
----> 1 data = rma.download(doc)

~/PyEnvironments/remarkable/lib/python3.8/site-packages/rmapy/api.py in download(self, document)
    241         log.debug("BLOB", document.BlobURLGet)
    242         r = self.request("GET", document.BlobURLGet, stream=True)
--> 243         return from_request_stream(document.ID, r)
    244 
    245     def delete(self, doc: DocumentOrFolder):

~/PyEnvironments/remarkable/lib/python3.8/site-packages/rmapy/document.py in from_request_stream(_id, stream)
    366         tmp.write(chunk)
    367     zd = ZipDocument(_id=_id)
--> 368     zd.load(tmp)
    369     return zd

~/PyEnvironments/remarkable/lib/python3.8/site-packages/rmapy/document.py in load(self, file)
    325                 thumbnail_name = p.replace(".rm", ".jpg")
    326                 thumbnail_name = thumbnail_name.replace("/", ".thumbnails/")
--> 327                 with zf.open(thumbnail_name, 'r') as tn:
    328                     thumbnail = BytesIO(tn.read())
    329                     thumbnail.seek(0)

/usr/lib/python3.8/zipfile.py in open(self, name, mode, pwd, force_zip64)
   1512         else:
   1513             # Get info object for name
-> 1514             zinfo = self.getinfo(name)
   1515 
   1516         if mode == 'w':

/usr/lib/python3.8/zipfile.py in getinfo(self, name)
   1439         info = self.NameToInfo.get(name)
   1440         if info is None:
-> 1441             raise KeyError(
   1442                 'There is no item named %r in the archive' % name)
   1443 

KeyError: "There is no item named '6be3ffeb-418e-454e-b618-3f846841d83f.thumbnails/0.jpg' in the archive"

can't get meta items

I'm encountering an issue when trying to get items (has the remarkable cloud API changed?). The code below fails:

[ins] In [2]: from rmapy.api import Client

[ins] In [3]: cl=Client()
[ins] In [5]: cl.register_device("matzkwqb")
Out[5]: True

[ins] In [6]: cl.is_auth()
Out[6]: False

[ins] In [7]: cl.is_auth()
Out[7]: False

[ins] In [8]: cl.renew_token()
Out[8]: True

[ins] In [9]: cl.is_auth()
Out[9]: True

[ins] In [10]: cl.get_meta_items()

Exception:

---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
<ipython-input-10-9767698c0b56> in <module>
----> 1 cl.get_meta_items()

~/.local/lib/python3.8/site-packages/rmapy/api.py in get_meta_items(self)
    178         collection = Collection()
    179         log.debug(response.text)
--> 180         for item in response.json():
    181             collection.add(item)
    182 

/usr/lib/python3.8/site-packages/requests/models.py in json(self, **kwargs)
    898                     # used.
    899                     pass
--> 900         return complexjson.loads(self.text, **kwargs)
    901 
    902     @property

/usr/lib64/python3.8/site-packages/simplejson/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw)
    523             parse_constant is None and object_pairs_hook is None
    524             and not use_decimal and not kw):
--> 525         return _default_decoder.decode(s)
    526     if cls is None:
    527         cls = JSONDecoder

/usr/lib64/python3.8/site-packages/simplejson/decoder.py in decode(self, s, _w, _PY3)
    368         if _PY3 and isinstance(s, bytes):
    369             s = str(s, self.encoding)
--> 370         obj, end = self.raw_decode(s)
    371         end = _w(s, end).end()
    372         if end != len(s):

/usr/lib64/python3.8/site-packages/simplejson/decoder.py in raw_decode(self, s, idx, _w, _PY3)
    398             elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf':
    399                 idx += 3
--> 400         return self.scan_once(s, idx=_w(s, idx).end())

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.