
A REPL wrapper for kaput-cli, a put.io client
kaput-cli is a great put.io client; use one of these 30-day free trial codes, if you want to try put.io yourself: , trial-code-1
, trial-code-3, trial-code-4.trial-code-2
I use it on my Raspberry Pi mini-dlna (aka ReadyMedia) media centre. It’s a node.js app and takes a couple of seconds to start on my tiny, resource-constrained Pi. My normal usage pattern is to look at the file list in put.io, click through the web UI to get the put.io file ID of the mp4
itself and then call kaput download <ID>
.
If you call kaput download
on the folder ID containing the piece of media you want instead of the media itself, kaput via the put.io API, will download a zip
of the files for you. I do this all the time by mistake and find it incredibly annoying, because minidlna expects to find a folder or a file, not a zip, especially as unzipping on the Pi can be slow too.
The other usage pattern I find myself doing frequently, is downloading a bunch of files in one session. kaput doesn’t have a multiple download option; you can’t say kaput download <ID1> <ID2> <ID3>
.
Initially I’d thought about forking kaput, but I wanted to see what the quickest thing I could do was. There’s a nice wrapper called with
that lets you turn any command into a REPL. The example they quote uses git
:
$ with git
git> add .
git> commit -a -m "Commited"
git> push
So I thought this would be a nice help for the slow start-up issue, plus wanting to download multiple IDs with kaput. You can use subcommand in with
too, so:
$ with kaput download
kaput download > 123456789
Gathering file info... done
The 39 Steps
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ | 2% | Progress: 33.17 MB/1.6 GB | ETA: 22m5s | Speed: 1.72 MB/s
It’s great and just works, but now I’m just staring at the progress bar whilst the file is downloading. What I really want, is to start another download before the first one completes.
I liked the idea of the REPL and once I’d started to think about it, wanted the ability to change and make folders within the REPL so I can organise files as I fetch them. Time for some bash!
I started off with a simple loop:
while true; do
read -p "kaslurp> " request
# do stuff with $request
end
And have ended up with the slightly more complex, but useful (to me) kaslurp
- a REPL wrapper for kaput-cli.
Basic usage is just kaslurp
you’ll get a REPL in the folder that’s defined as $MEDIADIR
(in my case, /mnt/video
). To download a put.io file, enter d <ID>
and it will download in the background. You can continue to use the REPL whilst this is happening, and even if you quit kaslurp
, any running downloads will complete. If you start with a -d
argument, this will override the starting $MEDIADIR
.
$ kaslurp
/mnt/video kaslurp> d 123456
Downloading 12345 in the background
/mnt/video kaslurp> cd Thrillers
/mnt/video/Thrillers kaslurp> ls
total 263MB
-rw-r--r-- 1 pi pi 263M Jan 1 21:31 Dressed_to_Kill_(1946).mp4
/mnt/video/Thrillers kaslurp> mkdir "Sherlock Holmes"
/mnt/video/Thrillers kaslurp> cd Sherlock\ Holmes
/mnt/video/Thrillers/Sherlock Holmes kaslurp>
As well as downloading, you can see from the example above that you can cd
, ls
and mkdir
all from within the REPL. kaslurp
also has a non-REPL mode too, where you can quickly background a download in the current directory or in a named one.
Usage: kaslurp
Start the REPL
kaslurp -d /some/path
Start the REPL at /some/path
kaslurp <put.io file ID>
Start a background download of <ID> to your current pwd and exit
kaslurp -d /some/path <put.io file ID>
Start a background download of <ID> to /some/path and exit
All links, in order of mention:
- kaput-cli: https://github.com/davidchalifoux/kaput-cli
- put.io: https://put.io
- trial-code-3: https://put.io/hi-friend/e7j0te6kf13eaa4nobys
- trial-code-4: https://put.io/hi-friend/ebnhm4uo3w908tbpaslq
- Raspberry Pi: https://www.raspberrypi.org/
- mini-dlna (aka ReadyMedia): https://sourceforge.net/projects/minidlna/
- node.js: https://nodejs.org/
- with: https://github.com/mchav/with
- REPL: https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop
- git: https://git-scm.com/
- kaslurp - a REPL wrapper for kaput-cli: https://github.com/jaygooby/kaslurp
Recent posts:
- Patch for aarch64 (aka arm64) openssl 1.0.2 'relocation R_AARCH64_PREL64 against symbol OPENSSL_armcap_P error'
- TIL: the `NO_COLOR` informal standard to suppress ANSI colour escape codes
- Copy the contents of a branch into an existing git branch without merging
- Adding search to a static Jekyll site using pagefind
- asdf, python and automatically enabling virtual envs