# jf-scan.j - scan the libraries with an API key and wait for the scan.# JELLYFIN_KEY=<your key> jennifer run jf-scan.juse io;
use os;
use time;
import"@deckyard/jellyfin/"as jellyfin;
funcscanTask(c asjellyfin.Client) {
for (def x injellyfin.tasks($c)) {
if ($x.key == "RefreshLibrary") {
return$x;
}
}
throw Error{kind: "value", message: "no RefreshLibrary task"};
}
def k asjellyfin.Client initjellyfin.withToken(
jellyfin.client("http://127.0.0.1:18096"), os.getEnv("JELLYFIN_KEY"));
jellyfin.refreshLibrary($k);
time.sleep(time.fromSeconds(1));
def t asjellyfin.Task initscanTask($k);
while ($t.state != "Idle") {
io.printf("%s: %s\n", $t.name, $t.state);
time.sleep(time.fromSeconds(2));
$t = scanTask($k);
}
io.printf("%s: %s\n", $t.name, $t.lastResult);