[PROD] refined php int

This commit is contained in:
Twarner491
2026-05-28 15:39:58 -07:00
parent ec167eac7b
commit 038b17c6c1
8 changed files with 48 additions and 42 deletions
+2 -2
View File
@@ -93,8 +93,8 @@ switch ($action) {
case 'recent': {
// Cap raised to 1,000,000 hours (~114 years) so the frontend's
// "ALL" button can effectively turn off the time filter without
// needing a separate code path.
// "ALL" button can turn off the time filter without needing a
// separate code path.
$hours = max(1, min(1000000, (int)($_GET['hours'] ?? 24)));
// species-collapsed view: one row per species seen in the window,
// with the file of its highest-confidence detection inside the window.
+3 -3
View File
@@ -5,7 +5,7 @@
// 1. ../assets/illustrations/<slug>.png (450+ bundled kachō-e renders)
// 2. ../assets/cutouts/<slug>.png (background-removed photo)
// 3. cached rembg of a Wikipedia photo at $HOME/BirdSongs/Extracted/cutouts/
// 4. fresh Wikipedia rembg cache (skipped gracefully if rembg unset)
// 4. fresh Wikipedia -> rembg -> cache (skipped gracefully if rembg unset)
//
// The frontend's <img src> points here for every species - bundled
// hits return instantly; cold misses fall through to the dynamic path.
@@ -76,8 +76,8 @@ if (is_file($cachePath) && filesize($cachePath) > 1024) {
}
// 4. Fresh Wikipedia fetch + rembg. Skipped if rembg-cli isn't on
// PATH - the resolver simply returns a 404 in that case rather
// than burning a Wikipedia request we can't use.
// PATH - the resolver returns a 404 in that case rather than
// burning a Wikipedia request we can't use.
$rembg = '/usr/local/bin/rembg-cli';
if (!is_executable($rembg)) {
http_response_code(404);
+3 -3
View File
@@ -7,7 +7,7 @@
// $HOME/BirdSongs/Extracted/By_Date/YYYY-MM-DD/<Common_Name>/<base>.mp3
// (with a matching .png next to it). Common_Name is the SPACE-stripped
// English common name (e.g. "Anna's_Hummingbird"), NOT the scientific
// name. We resolve sci common via birds.json under BirdNET-Pi/scripts/
// name. We resolve sci -> common via birds.json under BirdNET-Pi/scripts/
// and walk the directory tree newest-first.
//
@@ -96,7 +96,7 @@ if ($file !== '') {
readfile($path);
exit;
}
// ---- Resolve scientific name common name (with underscores) ----
// ---- Resolve scientific name -> common name (with underscores) ----
function resolve_common(string $sci): ?string {
// Try birds.json first (preferred - has clean sci/com pairs).
foreach ([dirname(__DIR__, 3) . '/BirdNET-Pi/scripts/birds.json'] as $f) {
@@ -131,7 +131,7 @@ function resolve_common(string $sci): ?string {
$common = resolve_common($sci);
if ($common === null) {
// Last-ditch: try the scientific name itself, with spaces underscores.
// Last-ditch: try the scientific name itself, with spaces -> underscores.
// (Some BirdNET dirs are keyed by sci name.)
$common = str_replace(' ', '_', $sci);
}
+2 -2
View File
@@ -5,8 +5,8 @@
// instead of .mp3.
//
// Endpoints:
// ?sci=<sci_name> newest spectrogram for that species
// ?file=<original-base>.mp3 spectrogram next to that specific
// ?sci=<sci_name> -> newest spectrogram for that species
// ?file=<original-base>.mp3 -> spectrogram next to that specific
// recording (atlas modal uses this so the
// strip below each play button is the
// spectrogram for that recording, not