add a ‘random unreviewed’ command
- ID
0d3fa13- date
2023-05-22 03:27:38+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
120fc6b- message
add a 'random unreviewed' command- changed files
3 files, 20 additions
Changed files
README.md (3184) → README.md (3239)
diff --git a/README.md b/README.md
index 9d430a7..13f554f 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,7 @@ I can use the following commands:
* `c` – add the photo to my "Cross stitch" album
* `o` – open the photo in Photos.app
* `u` – jump to the next photo which is unreviewed
+* `?` – jump to a random photo which is unreviewed
server.py (7349) → server.py (7734)
diff --git a/server.py b/server.py
index 8271a39..7fb413d 100755
--- a/server.py
+++ b/server.py
@@ -4,6 +4,7 @@ import collections
import functools
import json
import os
+import random
import subprocess
import sys
@@ -241,6 +242,20 @@ def next_unreviewed():
return b"", 404
+@app.route("/random-unreviewed")
+def random_unreviewed():
+ unreviewed_assets = [
+ asset["localIdentifier"]
+ for i, asset in enumerate(photos_data.all_assets)
+ if asset["state"] == "Unknown"
+ ]
+
+ try:
+ return redirect(url_for("index", localIdentifier=random.choice(unreviewed_assets)))
+ except IndexError:
+ return b"", 404
+
+
@app.route("/refresh", methods=["POST"])
def refresh():
photos_data.fetch_metadata()
static/reviewer.js (1276) → static/reviewer.js (1350)
diff --git a/static/reviewer.js b/static/reviewer.js
index 23e2d54..0d2c1a9 100644
--- a/static/reviewer.js
+++ b/static/reviewer.js
@@ -44,4 +44,8 @@ function handleKeyDown(event, thisIdentifier, nextIdentifier, prevIdentifier) {
case "u":
window.location = `/next-unreviewed?before=${thisIdentifier}`;
break;
+
+ case "?":
+ window.location = '/random-unreviewed';
+ break;
}}