Serve
downloader serve
serve answers JSON-line requests on stdin and writes replies and events on
stdout, one JSON object per line. A desktop app runs it as a child process and
drives the downloads through it. It exits when stdin closes and every request
has answered. Diagnostics go to stderr.
> {"id":1,"method":"resolve","params":{"url":"https://www.instagram.com/p/Df147tCiAyB/"}}
< {"event":"ready","data":{"protocol":1}}
< {"id":1,"ok":true,"data":{"url":"…","platform":"instagram","items":[…]}}
Messages
The first line out is {"event":"ready","data":{"protocol":1}}. A client
refuses a server whose protocol number it does not know.
A request is {id, method, params}. The id is any JSON value the client picks
and comes back on the reply. Requests run concurrently, so replies arrive in the
order they finish.
A reply is {id, ok: true, data} or {id, ok: false, error: {code, message}}.
The codes are the ones --json prints (see Script the command),
plus bad_request for a line that is not JSON (its id is null) and
no_method for an unknown method.
An event is {event, data}.
Methods
| Method | Params | Data |
|---|---|---|
resolve | {url} | {url, platform, items: [{type, url, filename}]} |
list | {target} | {listing, name, platform, posts, more} |
more | {listing} | {posts, more} |
download | {url, folder} | {url, files, skipped} |
history | {limit?} | [{url, files, at}], newest first, 100 by default |
session | {} | the saved account, "" without a name, or null |
login | {pasted} | {username} |
logout | {} | null |
list takes the same targets as the command line: @user, an Instagram profile
URL or a Facebook page URL. It returns the first page and a listing number;
more returns the next page of that listing. Each post carries saved, true
when the history holds it with its files on disk.
download saves one post into folder, which must be an absolute path. It
answers when the post is saved. Downloads run one at a time in the order they
arrive. A post the history holds with its files in that folder is skipped before
any request, and the reply says skipped: true. Each saved post is added to the
history the command line reads.
login takes a pasted sessionid or cookie export, checks it with Instagram
and saves it where downloader login does.
Events
progress reports bytes of one file of a download:
{
"event": "progress",
"data": {
"id": 3,
"filename": "Df147tCiAyB.jpg",
"received": 40960,
"total": 182044
}
}
id is the download request’s id. total is absent when the site does not
send a length.