mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Fix pagination, samples and previews
This commit is contained in:
@@ -18,7 +18,7 @@ class CoverController extends Controller
|
||||
public function show(string $type, string $filename)
|
||||
{
|
||||
// Validate cover type
|
||||
$validTypes = ['anime', 'audio', 'audiosample', 'book', 'console', 'games', 'movies', 'music', 'preview', 'sample', 'tvrage', 'video', 'xxx'];
|
||||
$validTypes = ['anime', 'audio', 'audiosample', 'book', 'console', 'games', 'movies', 'music', 'preview', 'sample', 'tvrage', 'video', 'xxx', 'tvshows'];
|
||||
|
||||
if (! in_array($type, $validTypes)) {
|
||||
abort(404);
|
||||
@@ -27,6 +27,18 @@ class CoverController extends Controller
|
||||
// Build the file path
|
||||
$filePath = storage_path("covers/{$type}/{$filename}");
|
||||
|
||||
// For preview and sample images, try with _thumb suffix if original doesn't exist
|
||||
if (! file_exists($filePath) && in_array($type, ['preview', 'sample'])) {
|
||||
// Try with _thumb suffix
|
||||
$pathInfo = pathinfo($filename);
|
||||
$thumbFilename = $pathInfo['filename'].'_thumb.'.($pathInfo['extension'] ?? 'jpg');
|
||||
$thumbPath = storage_path("covers/{$type}/{$thumbFilename}");
|
||||
|
||||
if (file_exists($thumbPath)) {
|
||||
$filePath = $thumbPath;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if file exists
|
||||
if (! file_exists($filePath)) {
|
||||
// Return placeholder image
|
||||
@@ -37,9 +49,19 @@ class CoverController extends Controller
|
||||
abort(404);
|
||||
}
|
||||
|
||||
// Determine content type
|
||||
$extension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
|
||||
$contentType = match ($extension) {
|
||||
'jpg', 'jpeg' => 'image/jpeg',
|
||||
'png' => 'image/png',
|
||||
'gif' => 'image/gif',
|
||||
'webp' => 'image/webp',
|
||||
default => 'image/jpeg',
|
||||
};
|
||||
|
||||
// Serve the file with proper headers
|
||||
return response()->file($filePath, [
|
||||
'Content-Type' => 'image/jpeg',
|
||||
'Content-Type' => $contentType,
|
||||
'Cache-Control' => 'public, max-age=31536000', // Cache for 1 year
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user