From 4fa433495b706a42439606d099cbec44e55cbc62 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Tue, 7 Feb 2023 23:01:26 +0100 Subject: [PATCH] Restore ability to download whole archives As API keys aren't written in the first line of JSON files. --- website/channels.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/website/channels.php b/website/channels.php index 3cf3936..0ae9cfa 100644 --- a/website/channels.php +++ b/website/channels.php @@ -14,10 +14,17 @@ $uri = $_SERVER['REQUEST_URI']; $uri = str_replace('/channels/', '', $uri); - $uri = str_replace('/', '#', $uri); - $uri = "/mnt/HDD0/YouTube_captions_search_engine/channels/$uri"; - header('Content-Type: application/json; charset=UTF-8'); - $content = file_get_contents("zip://$uri"); - echo stripFirstLine($content); + $prefix = '/mnt/HDD0/YouTube_captions_search_engine/channels/'; + if (str_contains($uri, '/')) { + $uri = str_replace('/', '#', $uri); + $uri = $prefix . $uri; + header('Content-Type: application/json; charset=UTF-8'); + $content = file_get_contents("zip://$uri"); + echo stripFirstLine($content); + } else { + $uri = $prefix . $uri; + header("Content-Type: application/zip"); + echo readfile($uri); + } ?>