`node select.js`: Open fzf/überzug menu to select a doujin. Shows a list of tags first. When a tag is selected, shows all doujins with that tag and lets the user select one, displaying the thumbnails of the doujins at the side. The "\*" tag can be used to search/select from all doujins.
+`node multiple-tags.js <tag1> <tag2> ...`: Open fzf/überzug menu with doujins that match all given tags (tags separated by whitespace).
+
`node stats-doujins.js`: Displays number of downloaded doujins, total size and average size per doujin
`node stats-tags.js`: Displays tags sorted by how many doujins are available for each tag. May produce long output, you might want to pipe it into `head`, `grep` or `less`.
const child = require("child_process")
-module.exports = dir => {
+module.exports = dirs => {
let res, rej
const prom = new Promise((rs, rj) => [res, rej] = [rs, rj])
- const proc = child.spawn("du", ["-b", "-L", dir])
+ const proc = child.spawn("du", ["-b", "-L", "-c", ...dirs])
let data = ""
proc.stdout.on("data", chunk => {
proc.on("close", code => {
if (code == 0)
- res(parseInt(data))
+ res(parseInt(data.split("\n").at(-2)))
else
rej(code)
})
const child = require("child_process")
-module.exports = (options, binary = "fzf") => {
+module.exports.fzf = (options, binary = "fzf") => {
let res, rej
const prom = new Promise((rs, rj) => [res, rej] = [rs, rj])
return prom
}
+
+module.exports.doujin = doujins => module.exports.fzf(doujins.sort(), __dirname + "/fzf-previews")
+ .then(doujin => child.spawn("firefox", [`file://${process.cwd()}/${doujin}/index.html`]))
+ .catch(_ => {})
--- /dev/null
+const fzf = require("./fzf")
+const info = require("./info")
+
+const tags = process.argv.slice(2)
+
+info.doujins()
+ .then(doujins => Object.values(doujins))
+ .then(doujins => doujins.filter(doujin =>
+ tags.every(tag => doujin.tag && doujin.tag.includes(tag))))
+ .then(doujins => doujins.map(doujin => doujin.title))
+ .then(doujins => fzf.doujin(doujins))
-const child = require("child_process")
const fzf = require("./fzf")
const info = require("./info")
;(async _ => {
- const doujins = await info.doujins()
const tags = await info.tags()
- let doujin, tag
- while (!doujin) {
- try { tag = await fzf(Object.keys(tags).sort()) } catch { return }
- try { doujin = await fzf(Object.values(tags[tag]).sort(), __dirname + "/fzf-previews") } catch {}
- }
-
- child.spawn("firefox", [`file://${process.cwd()}/${doujin}/index.html`])
+ do {
+ try {
+ tag = await fzf.fzf(Object.keys(tags).sort())
+ } catch {
+ return
+ }
+ } while (!await fzf.doujin(Object.values(tags[tag]).sort()))
})()
info.doujins()
.then(doujins => Object.keys(doujins))
- .then(doujins => Promise.all(doujins.map(du))
- .then(sizes => sizes.reduce((a, b) => a + b, 0))
- .then(total => console.log(fmt(doujins.length, total)))
- )
+ .then(doujins => du(doujins)
+ .then(total => console.log(fmt(doujins.length, total))))