YouTube_captions_search_engine/website/channels.php
Benjamin Loison 4fa433495b
Restore ability to download whole archives
As API keys aren't written in the first line of JSON files.
2023-02-07 23:01:26 +01:00

31 lines
838 B
PHP

<?php
function stripFirstLine($text)
{
return substr($text, strpos($text, "\n") + 1);
}
if (!function_exists('str_contains')) {
function str_contains($haystack, $needle)
{
return strpos($haystack, $needle) !== false;
}
}
$uri = $_SERVER['REQUEST_URI'];
$uri = str_replace('/channels/', '', $uri);
$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);
}
?>