shaarli / Shaarli

The personal, minimalist, super-fast, database free, bookmarking service - community repo
https://shaarli.readthedocs.io/
Other
3.41k stars 291 forks source link

Packaged REST API client #745

Closed virtualtam closed 7 years ago

virtualtam commented 7 years ago

Hi!

I've started to write a simple REST client to test API-related Pull Requests (see early stubs on #739); would there be interest in providing an "official" Shaarli client to manipulate a Shaarli instance through its REST API?

The client would:

And could potentially:

ping @nodiscc @ArthurHoaro :)

ArthurHoaro commented 7 years ago

That could definitely be useful, if you're willing to work on it!

However I don't see what youtube-dl and PyAV have to do with this...

virtualtam commented 7 years ago

youtube-dl is already used by shaarchiver to download media from shaares' URLs, and PyAV provides bindings to ffmpeg/libav, e.g. to only process the audio part of a downloaded video (might be overkill ^^)

ArthurHoaro commented 7 years ago

Oh ok. Well, why not. But at first, having a real client which is able to use the API properly would be awesome. Additional features should come after that.

nodiscc commented 7 years ago

I would definitely use a proper command-line client for Shaarli, and am willing to rewrite shaarchiver around the API. It was primarily a first experiment with Python (but proved useful), so a full rewrite is in order.

What it could use is a client that is just able to:

Scripts could fulfill the role shaarchiver used to have, and stay out of the reference API client code. Some example scripts of what could be done, separately. Again these should stay out of the reference client code, with their own youtube-dl/libavffmpeg/... dependencies, but it's good if the client provides comfort/flexibility to achieve more complex work.

In short I'd be glad to help on a python+requests+jwt+pytest (been wanting to try pytest for a long time) client :p and write assorted "extractors" to extend it.

(If you have good resources to share about python-jwt/tox, please do)!

virtualtam commented 7 years ago

pass each query result's contents as command-line arguments

This can be an issue, I've seen Bash shell buffers overflowed and data lost this way ^^

What it could use is a client that is just able to:

  • get links by name, url, tags, id, date/timerange, private...
  • pass each query result's contents as command-line arguments, to custom scripts (eg scripts/*.py).

Scripts could fulfill the role shaarchiver used to have

A bare API connector would have quite a limited use (consisting in simple API calls), the added value comes from providing extra/useful features such as dumping links, downloading media, scraping content, etc.

This can be structured in a simple way:

Note that it's possible to mark some features as being optional, in which case they're available only if the user has installed the appropriate dependencies.

I would definitely use a proper command-line client for Shaarli, and am willing to rewrite shaarchiver around the API. It was primarily a first experiment with Python (but proved useful), so a full rewrite is in order.

Should we fork shaarchiver and refactor the existing scripts a bit for packaging, then start adding REST features? Or start a new project from scratch?

nodiscc commented 7 years ago

I'd rather start fresh with a new project (core API package). @virtualtam If you can lay down the basics of the architecture you described above (I fully agree) in a new repo of the Shaarli org that would be great.

virtualtam commented 7 years ago

Cool! @ArthurHoaro @nodiscc do you have a naming preference for the new project? I was thinking something in the lines of python-shaarli-client, more inspired ideas are welcome ;-)

virtualtam commented 7 years ago

Closing as work has been started, see https://github.com/shaarli/python-shaarli-client/