]> git.lizzy.rs Git - local-nhentai.git/blobdiff - select.js
Generic stats and select
[local-nhentai.git] / select.js
index 6938749cdaeb166e649688f1341f15eb6fe74635..bf4c4f7ca0b063c41edd059f49395b26a0192780 100644 (file)
--- a/select.js
+++ b/select.js
@@ -1,16 +1,27 @@
-const child = require("child_process")
 const fzf = require("./fzf")
 const info = require("./info")
 
 ;(async _ => {
-       const doujins = await info.doujins()
-       const tags = await info.tags()
+       const criteria = await info.criteria()
+       let stage = 0
+       let crt, val, dou
 
-       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 {}
-       }
+       while (true) {
+               try {
+                       switch (stage) {
+                               case 0:
+                                       crt = await fzf.fzf(Object.keys(criteria).sort()); break
+                               case 1:
+                                       val = await fzf.fzf(Object.keys(criteria[crt]).sort()); break
+                               case 2:
+                                       dou = await fzf.doujin(Object.values(criteria[crt][val]).sort()); break
+                               default:
+                                       return
+                       }
 
-       child.spawn("firefox", [`file://${process.cwd()}/${doujin}/index.html`])
+                       stage++
+               } catch {
+                       stage--
+               }
+       }
 })()