jellyfin music :)

This commit is contained in:
Lars Behrends
2025-11-10 05:06:26 +01:00
parent 0530f00cbf
commit aed9d87c5c
10 changed files with 1994 additions and 94 deletions

View File

@@ -472,7 +472,7 @@ class AdminController extends AdminBaseController
// Validate sync type based on source type
if ($source['name'] === 'jellyfin') {
$validSyncTypes = ['full', 'incremental', 'all', 'movies', 'tvshows', 'cleanup'];
$validSyncTypes = ['full', 'incremental', 'all', 'movies', 'tvshows', 'music', 'cleanup'];
if (!in_array($syncType, $validSyncTypes)) {
return $this->json($response, [
'success' => false,

View File

@@ -27,21 +27,43 @@ class MusicController extends Controller
// Get search parameters
$search = trim($queryParams['search'] ?? '');
// Get filter parameters
$genres = $queryParams['genres'] ?? [];
if (!is_array($genres)) {
$genres = [$genres];
}
$genres = array_filter($genres);
$artists = $queryParams['artists'] ?? [];
if (!is_array($artists)) {
$artists = [$artists];
}
$artists = array_filter($artists);
// Get view mode
$viewMode = $queryParams['view'] ?? 'grid'; // grid, list, covers
// For now, return empty arrays since Music isn't implemented yet
$music = [];
$totalCount = 0;
// Get sort parameter
$sort = $queryParams['sort'] ?? 'title_asc';
// Get albums with pagination, filters, and sorting
$albums = \App\Models\MusicAlbum::getAllWithPagination($this->pdo, $page, $perPage, $search, $genres, $artists, $sort);
// Get total count for pagination
$totalCount = \App\Models\MusicAlbum::getTotalCount($this->pdo, $search, $genres, $artists);
// Get available filter options
$availableGenres = \App\Models\MusicAlbum::getAvailableGenres($this->pdo);
$availableArtists = \App\Models\MusicAlbum::getAvailableArtists($this->pdo);
// Calculate pagination info
$totalPages = 0;
$hasNextPage = false;
$hasPrevPage = false;
$totalPages = ceil($totalCount / $perPage);
$hasNextPage = $page < $totalPages;
$hasPrevPage = $page > 1;
return $this->view->render($response, 'music/index.twig', [
'title' => 'Music',
'music' => $music,
'albums' => $albums,
'pagination' => [
'current_page' => $page,
'per_page' => $perPage,
@@ -54,19 +76,79 @@ class MusicController extends Controller
],
'search' => $search,
'view_mode' => $viewMode,
'view_modes' => ['grid', 'list', 'covers']
'view_modes' => ['grid', 'list', 'covers'],
'filters' => [
'genres' => $genres,
'artists' => $artists
],
'available_filters' => [
'genres' => $availableGenres,
'artists' => $availableArtists
],
'sort' => $sort,
'sort_options' => [
'title_asc' => 'Title (A-Z)',
'title_desc' => 'Title (Z-A)',
'artist_asc' => 'Artist (A-Z)',
'artist_desc' => 'Artist (Z-A)',
'release_desc' => 'Release Date (Newest First)',
'release_asc' => 'Release Date (Oldest First)',
'added_desc' => 'Recently Added',
'added_asc' => 'Oldest Added'
]
]);
}
public function show(Request $request, Response $response, $args)
{
$musicId = (int) $args['id'];
$albumId = (int) $args['id'];
// Get album details
$stmt = $this->pdo->prepare("
SELECT ma.*, s.display_name as source_name
FROM music_albums ma
JOIN sources s ON ma.source_id = s.id
WHERE ma.id = :id
");
$stmt->execute(['id' => $albumId]);
$album = $stmt->fetch(\PDO::FETCH_ASSOC);
if (!$album) {
return $response->withStatus(404);
}
// Decode metadata for display
$metadata = json_decode($album['metadata'], true);
// Get tracks for this album
$stmt = $this->pdo->prepare("
SELECT mt.*
FROM music_tracks mt
WHERE mt.album_id = :album_id
ORDER BY mt.track_number ASC, mt.title ASC
");
$stmt->execute(['album_id' => $albumId]);
$tracks = $stmt->fetchAll(\PDO::FETCH_ASSOC);
// Get artist information
$artist = null;
if ($album['artist_id']) {
$stmt = $this->pdo->prepare("
SELECT ma.*, s.display_name as source_name
FROM music_artists ma
JOIN sources s ON ma.source_id = s.id
WHERE ma.id = :artist_id
");
$stmt->execute(['artist_id' => $album['artist_id']]);
$artist = $stmt->fetch(\PDO::FETCH_ASSOC);
}
// For now, return a placeholder since Music isn't implemented yet
return $this->view->render($response, 'music/show.twig', [
'title' => 'Music Details',
'music' => ['id' => $musicId, 'title' => 'Coming Soon'],
'message' => 'Music details page is not yet implemented.'
'title' => $album['title'],
'album' => $album,
'tracks' => $tracks,
'artist' => $artist,
'metadata' => $metadata
]);
}
}