subutux / rmapy

A unofficial python module for interacting with the Remarkable Cloud
http://rmapy.readthedocs.io/
MIT License
125 stars 48 forks source link

can't get meta items #23

Closed cycomanic closed 3 years ago

cycomanic commented 3 years ago

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)
dancorne commented 3 years ago

I'm getting the same error, it turns out the API domain name has changed, see eg https://github.com/juruen/rmapi/issues/177

Doing a similar URL update seems to fix it.

edsu commented 3 years ago

I ran into this too, it would be super nice to get the fix applied here!

subutux commented 3 years ago

Hi all, Busy few months here. Mea culpa for the delay. I’ll take a look at the pull request tonight.